मॉड्यूल:Sandbox/Santi2222/rmq-headword
दिखावट
"इस मॉड्यूल हेतु प्रलेख मॉड्यूल:Sandbox/Santi2222/rmq-headword/doc पर बनाया जा सकता है"
local export = {}
local lang = require("Module:languages").getByCode("rmq")
--nouns
function export.show_noun(frame)
local args = frame:getParent().args
local data = {lang = lang, pos_category = "nouns", categories = {}, sort_key = args.sort, heads = {args.head}, genders, inflections = {}}
local tracking_categories = {}
--define variables
local stem = mw.title.getCurrentTitle().text
if args.head then --in case a different headword is specified
stem = args.head
end
local short_stem = stem:sub(1, -2)
local ending = ""
--add gender
local g, genders = args.g or args[1]
if g == "m" then
data.genders = { "m" }
elseif g == "f" then
data.genders = { "f" }
elseif g == "both" then
data.genders = { "m","f" }
else
data.genders = { "?" }
end
--find ending
ending = stem:sub(-1)
if stem:sub(-2,-1) == "ay" then
stem = stem:sub(1, -3)
ending = "ay"
elseif stem:sub(-2,-1) == "oy" then
stem = stem:sub(1, -3)
ending = "oy"
elseif stem:sub(-2,-1) == "uy" then
stem = stem:sub(1,-3)
ending = "uy"
elseif stem:sub(-2,-1) == "ó" then
stem = stem:sub(1,-3)
ending = "ó"
elseif stem:sub(-2,-1) == "í" then
ending = "í"
elseif ending == "y" then
stem = stem:sub(1,-2)
end
--generate plurals
local pl = args.pl or args[2]
if pl then
if pl == "-" then
table.insert(data.categories, "Caló uncountable nouns")
data.inflections = {{label = "uncountable"}}
else
data.inflections = {{label = "plural", pl}}
end
else
if ending == "ay" then
data.inflections = {{label = "plural", stem .. "áes"}}
elseif ending == "oy" then
data.inflections = {{label = "plural", stem .. "ayes"}}
elseif ending == "uy" then
data.inflections = {{label = "plural", stem .. "úes"}}
elseif ending == "y" then
data.inflections = {{label = "plural", stem .. "ís"}}
elseif ending == "ó" then
data.inflections = {{label = "plural", stem .. "és" }}
elseif ending == "í" then
data.inflections = {{label = "plural", stem .. "as"}}
elseif ('aeiouáé'):match(ending) then
data.inflections = {{label = "plural", stem .. "s"}}
else
data.inflections = {{label = "plural", stem .. "es"}}
end
end
return require("Module:headword").full_headword(data) ..
require("Module:utilities").format_categories(tracking_categories, lang, args.sort)
end
return export