local export = {}
local pos_functions = {}
local match = mw.ustring.match
local gsub = mw.ustring.gsub
local lang = require("Module:languages").getByCode("te")
local PAGENAME = mw.title.getCurrentTitle().text
local script = require("Module:scripts").getByCode("Telu")
function export.show(frame)
local args = frame:getParent().args
local poscat = frame.args or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local data = {lang = lang, sc = script, pos_category = poscat, categories = {}, heads = {args}, genders = {}, inflections = {}}
if pos_functions then
pos_functions(args, data)
end
return require("Module:headword").full_headword(data)
end
-- TODO
local function pluralize(sn)
local pn
-- do not swap
if match(sn, "ుడు$") then -- -uDu > -ulu
pn = gsub(sn, "ుడు$", "ులు")
elseif match(sn, "డ్డ$") then -- -DDi,-DDu > -Dlu
pn = gsub(sn, "డ్డ$", "డ్లు")
elseif match(sn, "డి$") then -- -Di > -LLu
pn = gsub(sn, "డి$", "ళ్ళు")
elseif match(sn, "ు$") then -- -Du,-lu,-ru > -LLu
pn = gsub(sn, "ు$", "ళ్ళు")
elseif match(sn, "ట్ట$") then -- -TTi,-TTu > -Tlu
pn = gsub(sn, "ట్ట$", "ట్లు")
elseif match(sn, "టు$") then -- -Tu > -Tlu
pn = gsub(sn, "టు$", "ట్లు")
elseif match(sn, "()ం$") then -- -aM > -Alu
pn = gsub(sn, "()ం$", "%1ాలు")
elseif match(sn, "ెం$") then -- -eM > -Elu
pn = gsub(sn, "ెం$", "ేలు")
elseif match(sn, "ి$") then -- -i > -ulu
pn = gsub(sn, "ి$", "ులు")
else
pn = sn .. "లు"
end
return pn
end
pos_functions = function(args, data)
local plurals = {label = "plural"}
if not args then
table.insert(plurals, pluralize(PAGENAME))
table.insert(data.inflections, plurals)
elseif args == "-" then
table.insert(data.inflections, {label = "singular only"})
table.insert(data.categories, "Telugu singularia tantum")
elseif args == "+" then
table.insert(data.inflections, {label = "plural only"})
table.insert(data.categories, "Telugu pluralia tantum")
else
for _,par in ipairs(args) do
table.insert(plurals, par)
end
table.insert(data.inflections, plurals)
end
table.insert(data.genders, args or "?")
end
pos_functions = function(args, data)
local plurals = {label = "plural"}
if not args then
-- do nothing
elseif args == "+" then
table.insert(data.inflections, {label = "plural only"})
table.insert(data.categories, "Telugu pluralia tantum")
else
for _,par in ipairs(args) do
table.insert(plurals, par)
end
table.insert(data.inflections, plurals)
end
table.insert(data.genders, args or "?")
end
return export