Module:User:Victar/iir-nouns

local lang = require("Module:languages").getByCode("gmw-pro")

local export = {}

local genders = { ["m"] = "masculine", ["f"] = "feminine", ["n"] = "neuter", }

-- Inflection functions

function export.a(frame) local params = { [1] = {default = mw.title.getCurrentTitle.nsText == "Template" and "ás" or mw.title.getCurrentTitle.subpageText},

["g"] = {required = true, default = "m"}, ["n"] = {}, }

local args = require("Module:parameters").process(frame:getParent.args, params)

local data = { forms = {}, info = nil, categories = {}, }

local stem, suffix = mw.ustring.match(args[1], "^(.-)(ás)$")

if suffix ~= "ás" then error("a-stems must end in -ás") end data.info = "a-stem" table.insert(data.categories, lang:getCanonicalName .. " a-stem nouns") data.forms["nom|s"] = {stem .. "ás"} data.forms["voc|s"] = {stem .. "á"} data.forms["acc|s"] = {stem .. "ám"} data.forms["ins|s"] = {stem .. "ā́"} data.forms["abl|s"] = {stem .. "ā́t"} data.forms["dat|s"] = {stem .. "ā́y"} data.forms["gen|s"] = {stem .. "ásya"} data.forms["loc|s"] = {stem .. "áy"} data.forms["nom|d"] = {stem .. "ā́"} data.forms["voc|d"] = data.forms["nom|d"] data.forms["acc|d"] = data.forms["nom|d"] data.forms["ins|d"] = {stem .. "áybʰyaH", stem .. "ā́bʰyām"} data.forms["abl|d"] = data.forms["ins|d"] data.forms["dat|d"] = data.forms["ins|d"] data.forms["gen|d"] = {stem .. "áyās"} data.forms["loc|d"] = {stem .. "áyaw"} data.forms["nom|p"] = {stem .. "ā́", stem .. "ā́s(as)"} data.forms["voc|p"] = data.forms["nom|p"] data.forms["acc|p"] = {stem .. "ā́ns"} data.forms["ins|p"] = {stem .. "ā́yš"} data.forms["abl|p"] = {stem .. "áybʰyas"} data.forms["dat|p"] = data.forms["abl|p"] data.forms["gen|p"] = {stem .. "ā́na(H)m"} data.forms["loc|p"] = {stem .. "áyšu"}

postprocess(args, data) return make_table(data) end

function postprocess(args, data) data.n = args["n"] if args["n"] == "p" then table.insert(data.categories, lang:getCanonicalName .. " pluralia tantum") elseif args["n"] == "s" then table.insert(data.categories, lang:getCanonicalName .. " singularia tantum") elseif args["n"] then error("args= must be \"s\" or \"p\".") end

for key, form in pairs(data.forms) do		-- Do not show singular or plural forms for nominals that don't have them if (args["n"] == "p" and key:find("|s$")) or (args["n"] == "s" and key:find("|p$")) then form = nil end

data.forms[key] = form end end

-- Make the table function make_table(data) local function repl(param) if param == "info" then return mw.getContentLanguage:ucfirst(data.info or "") end local forms = data.forms[param] if not forms then return "&mdash;" end local ret = {} for key, subform in ipairs(forms) do table.insert(ret, require("Module:links").full_link({lang = lang, alt = "*" .. subform})) end return table.concat(ret, ", ") end local wikicode = {} table.insert(wikicode, [=[

return mw.ustring.gsub(table.concat(wikicode), "", repl) .. require("Module:utilities").format_categories(data.categories, lang) end

return export