Module:te-headword
Appearance
- The following documentation is located at Module:te-headword/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
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[1] 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["head"]}, genders = {}, inflections = {}}
if pos_functions[poscat] then
pos_functions[poscat](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["nouns"] = function(args, data)
local plurals = {label = "plural"}
if not args[1] then
table.insert(plurals, pluralize(PAGENAME))
table.insert(data.inflections, plurals)
elseif args[1] == "-" then
table.insert(data.inflections, {label = "singular only"})
table.insert(data.categories, "Telugu singularia tantum")
elseif args[1] == "+" 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["g"] or "?")
end
pos_functions["proper nouns"] = function(args, data)
local plurals = {label = "plural"}
if not args[1] then
-- do nothing
elseif args[1] == "+" 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["g"] or "?")
end
return export