Module:se-nominals

local lang = require("Module:languages").getByCode("se")

local export = {}

local possessives = { ["1|s"] = {even = "n", odd = "an"}, ["2|s"] = {even = "t", odd = "at"}, ["3|s"] = {even = "s", odd = "is"}, ["1|d"] = {even = "me", odd = "eamẹ"}, ["2|d"] = {even = "de", odd = "eattẹ"}, ["3|d"] = {even = "ska", odd = "easkkạ"}, ["1|p"] = {even = "met", odd = "eamẹt"}, ["2|p"] = {even = "det", odd = "eattẹt"}, ["3|p"] = {even = "set", odd = "easẹt"}, }

-- Inflection functions

function export.even(frame) local fparams = { [1] = {required = true}, ["nograd"] = {type = "boolean"}, }	local fargs = require("Module:parameters").process(frame.args, fparams) local params = { [1] = {required = true, default = ""}, ["attr"] = fargs[1] == "adjectives" and {list = true} or nil, ["e"] = fargs[1] == "adjectives" and {type = "boolean"} or nil, ["n"] = fargs[1] == "nouns" and {} or nil, ["novowel"] = {type = "boolean"}, ["poss"] = fargs[1] == "nouns" and {} or nil, }	local args = require("Module:parameters").process(frame:getParent.args, params) local stem = require("Module:se-common").Stem(args[1], not fargs["nograd"]) local data = { has_attr = fargs[1] == "adjectives", has_poss = fargs[1] == "nouns" and not args["poss"], forms = {}, info = "even " .. require("Module:links").full_link({lang = lang, alt = stem.uvowel}, "term") .. "-stem", categories = {}, }	if stem.gradation then data.info = data.info .. ", " ..			require("Module:links").full_link({lang = lang, alt = stem.gradation.strong.scons}, "term") .. "-" ..			require("Module:links").full_link({lang = lang, alt = stem.gradation.weak.scons}, "term") .. " gradation" else data.info = data.info .. ", no gradation" end if args["e"] and not stem.uvowel == "i" then error("The parameter \"e=1\" must be used with stems ending in -i.") elseif not mw.ustring.find(stem.uvowel, "^[aáeiou]$") and mw.title.getCurrentTitle.nsText ~= "Template" then error("The final vowel(s) of the stem must be one of a, á, e, i, o, u.") end if fargs[1] == "nouns" and args["poss"] and args["poss"] ~= "-" then local poss = possessives[args["poss"]:gsub("_", "|")] data.forms["nom|s"] = {stem:make_form{grade = "strong", ending = poss.even, variant = mw.ustring.find(args["poss"], "3") and "normal" or "e"}} data.forms["acc|s"] = {stem:make_form{grade = mw.ustring.find(args["poss"], "1") and "strong" or "weak", ending = poss.even, variant = mw.ustring.find(args["poss"], "3") and "normal" or "e"}} data.forms["gen|s"] = {stem:make_form{grade = mw.ustring.find(args["poss"], "1") and "strong" or "weak", ending = poss.even, variant = mw.ustring.find(args["poss"], "3") and "normal" or "e"}} data.forms["ill|s"] = {stem:make_form{grade = "strong", ending = "s" .. poss.odd, variant = "e"}} data.forms["loc|s"] = {stem:make_form{grade = "weak", ending = "st" .. poss.odd}} data.forms["com|s"] = {stem:make_form{grade = "weak", ending = "in" .. poss.odd, variant = "j"}} data.forms["nom|p"] = nil data.forms["acc|p"] = {stem:make_form{grade = "weak", ending = "id" .. poss.odd, variant = "j"}} data.forms["gen|p"] = {stem:make_form{grade = "weak", ending = "id" .. poss.odd, variant = "j"}} data.forms["ill|p"] = {stem:make_form{grade = "weak", ending = "idasa" .. poss.even, variant = "j"}} data.forms["loc|p"] = {stem:make_form{grade = "weak", ending = "in" .. poss.odd, variant = "j"}} data.forms["com|p"] = {stem:make_form{grade = "weak", ending = "id" .. poss.odd .. "guin", variant = "j"}} data.forms["ess"]  = {stem:make_form{grade = "strong", ending = "n" .. poss.odd}} else table.insert(data.categories, lang:getCanonicalName .. " even " .. fargs[1]) table.insert(data.categories, lang:getCanonicalName .. " even " .. (stem.uvowel or "") .. "-stem " .. fargs[1]) if not stem.gradation then table.insert(data.categories, lang:getCanonicalName .. " non-gradating even " .. fargs[1]) end data.forms["nom|s"] = {stem:make_form{grade = "strong", variant = args["novowel"] and "none" or args["e"] and "short" or nil}} data.forms["acc|s"] = {stem:make_form{grade = "weak"}} data.forms["gen|s"] = {stem:make_form{grade = "weak"}, fargs[1] == "nouns" and stem:make_form{grade = "weak", variant = "short"} or nil} data.forms["ill|s"] = {stem:make_form{grade = "strong", ending = "i", variant = "e_contr_j"}} data.forms["loc|s"] = {stem:make_form{grade = "weak", ending = "s"}} data.forms["com|s"] = {stem:make_form{grade = "weak", ending = "in", variant = "j"}} data.forms["nom|p"] = {stem:make_form{grade = "weak", ending = "t"}} data.forms["acc|p"] = {stem:make_form{grade = "weak", ending = "id", variant = "j"}} data.forms["gen|p"] = {stem:make_form{grade = "weak", ending = "id", variant = "j"}} data.forms["ill|p"] = {stem:make_form{grade = "weak", ending = "ide", variant = "j"}} data.forms["loc|p"] = {stem:make_form{grade = "weak", ending = "in", variant = "j"}} data.forms["com|p"] = {stem:make_form{grade = "weak", ending = "iguin", variant = "j"}} data.forms["ess"]   = {stem:make_form{grade = "strong", ending = "n"}} if fargs[1] == "nouns" then data.forms["1|s|poss"] = {stem:make_form{grade = "strong", ending = "n", variant = "e"}} data.forms["2|s|poss"] = {stem:make_form{grade = "strong", ending = "t", variant = "e"}} data.forms["3|s|poss"] = {stem:make_form{grade = "strong", ending = "s"}} data.forms["1|d|poss"] = {stem:make_form{grade = "strong", ending = "me", variant = "e"}} data.forms["2|d|poss"] = {stem:make_form{grade = "strong", ending = "de", variant = "e"}} data.forms["3|d|poss"] = {stem:make_form{grade = "strong", ending = "ska"}} data.forms["1|p|poss"] = {stem:make_form{grade = "strong", ending = "met", variant = "e"}} data.forms["2|p|poss"] = {stem:make_form{grade = "strong", ending = "det", variant = "e"}} data.forms["3|p|poss"] = {stem:make_form{grade = "strong", ending = "set"}} end if data.forms["gen|s"][2] == data.forms["gen|s"][1] then data.forms["gen|s"][2] = nil end end postprocess(args, data) return make_table(data) end

function export.odd(frame) local fparams = { [1] = {required = true}, ["nograd"] = {type = "boolean"}, }	local fargs = require("Module:parameters").process(frame.args, fparams) local params = { [1] = {default = mw.title.getCurrentTitle.nsText == "Template" and "" or ""}, ["attr"] = fargs[1] == "adjectives" and {list = true} or nil, ["final"] = {}, ["n"] = fargs[1] == "nouns" and {} or nil, ["noapocope"] = not fargs["nograd"] and {type = "boolean"} or nil, ["noumlaut"] = not fargs["nograd"] and {type = "boolean"} or nil, ["poss"] = fargs[1] == "nouns" and {} or nil, ["Q31"] = not fargs["nograd"] and {type = "boolean"} or nil, }	local args = require("Module:parameters").process(frame:getParent.args, params) local strong = require("Module:se-common").Stem(args[1], args["Q31"] and "Q31" or not fargs["nograd"], args["final"]) local weak = require("Module:se-common").Stem(args[1], args["Q31"] and "Q31" or not fargs["nograd"], args["final"]) local variant = nil if args["attr"] and args["attr"][1] ~= "-" then if args["attr"][1] then require("Module:debug").track("se-nominals/attr") else require("Module:debug").track("se-nominals/no attr") end end local data = { has_attr = fargs[1] == "adjectives", has_poss = fargs[1] == "nouns" and not args["poss"], forms = {}, info = "odd", categories = {}, }	if strong.gradation then if not args["noumlaut"] then variant = "e" end if not args["noapocope"] and mw.ustring.find(weak.ucons, "^[gmn]$") then weak.ucons = "" end data.info = data.info .. ", " ..			require("Module:links").full_link({lang = lang, alt = strong.gradation.strong.scons}, "term") .. "-" ..			require("Module:links").full_link({lang = lang, alt = strong.gradation.weak.scons}, "term") .. " gradation" else data.info = data.info .. ", no gradation" end if strong.ucons == "" and mw.title.getCurrentTitle.nsText ~= "Template" then error("The strong-grade stem must end in a consonant.") end if fargs[1] == "nouns" and args["poss"] and args["poss"] ~= "-" then local poss = possessives[args["poss"]:gsub("_", "|")] data.forms["nom|s"] = {strong:make_form{grade = "strong", ending = poss.odd, variant = variant}} data.forms["acc|s"] = {strong:make_form{grade = "strong", ending = poss.odd, variant = variant}} data.forms["gen|s"] = {strong:make_form{grade = "strong", ending = poss.odd, variant = variant}} data.forms["ill|s"] = {strong:make_form{grade = "strong", ending = "asa" .. poss.even, variant = variant}} data.forms["loc|s"] = {strong:make_form{grade = "strong", ending = "istt" .. (mw.ustring.find(args["poss"], "3") and "i" or "á") .. poss.even, variant = variant}} data.forms["com|s"] = {strong:make_form{grade = "strong", ending = "iinn" .. (mw.ustring.find(args["poss"], "3") and "i" or "á") .. poss.even, variant = variant}} data.forms["nom|p"] = nil data.forms["acc|p"] = {strong:make_form{grade = "strong", ending = "iidd" .. (mw.ustring.find(args["poss"], "3") and "i" or "á") .. poss.even, variant = variant}} data.forms["gen|p"] = {strong:make_form{grade = "strong", ending = "iidd" .. (mw.ustring.find(args["poss"], "3") and "i" or "á") .. poss.even, variant = variant}} data.forms["ill|p"] = {strong:make_form{grade = "strong", ending = "iiddás" .. poss.odd, variant = variant}} data.forms["loc|p"] = {strong:make_form{grade = "strong", ending = "iinn" .. (mw.ustring.find(args["poss"], "3") and "i" or "á") .. poss.even, variant = variant}} data.forms["com|p"] = {strong:make_form{grade = "strong", ending = "iidd" .. (mw.ustring.find(args["poss"], "3") and "i" or "á") .. poss.even .. "guin", variant = variant}} data.forms["ess"]   = {weak:make_form{grade = "weak", ending = (weak.ucons == "" and "" or "i") .. "n" .. (weak.ucons == "" and poss.odd or "i" .. poss.even)}} else table.insert(data.categories, lang:getCanonicalName .. " odd " .. fargs[1]) if strong.gradation then table.insert(data.categories, lang:getCanonicalName .. " gradating odd " .. fargs[1]) else table.insert(data.categories, lang:getCanonicalName .. " non-gradating odd " .. fargs[1]) end data.forms["nom|s"] = {weak:make_form{grade = "weak"}} data.forms["acc|s"] = {strong:make_form{grade = "strong", ending = "a", variant = variant}} data.forms["gen|s"] = {strong:make_form{grade = "strong", ending = "a", variant = variant}} data.forms["ill|s"] = {strong:make_form{grade = "strong", ending = "ii", variant = variant}} data.forms["loc|s"] = {strong:make_form{grade = "strong", ending = "is", variant = variant}} data.forms["com|s"] = {strong:make_form{grade = "strong", ending = "iin", variant = variant}} data.forms["nom|p"] = {strong:make_form{grade = "strong", ending = "at", variant = variant}} data.forms["acc|p"] = {strong:make_form{grade = "strong", ending = "iid", variant = variant}} data.forms["gen|p"] = {strong:make_form{grade = "strong", ending = "iid", variant = variant}} data.forms["ill|p"] = {strong:make_form{grade = "strong", ending = "iidda", variant = variant}} data.forms["loc|p"] = {strong:make_form{grade = "strong", ending = "iin", variant = variant}} data.forms["com|p"] = {strong:make_form{grade = "strong", ending = "iiguin", variant = variant}} data.forms["ess"]   = {weak:make_form{grade = "weak", ending = (weak.ucons == "" and "" or "i") .. "n"}} if fargs[1] == "nouns" then data.forms["1|s|poss"] = {strong:make_form{grade = "strong", ending = "an", variant = variant}} data.forms["2|s|poss"] = {strong:make_form{grade = "strong", ending = "at", variant = variant}} data.forms["3|s|poss"] = {strong:make_form{grade = "strong", ending = "is", variant = variant}} data.forms["1|d|poss"] = {strong:make_form{grade = "strong", ending = "eamẹ", variant = variant}} data.forms["2|d|poss"] = {strong:make_form{grade = "strong", ending = "eattẹ", variant = variant}} data.forms["3|d|poss"] = {strong:make_form{grade = "strong", ending = "easkkạ", variant = variant}} data.forms["1|p|poss"] = {strong:make_form{grade = "strong", ending = "eamẹt", variant = variant}} data.forms["2|p|poss"] = {strong:make_form{grade = "strong", ending = "eattẹt", variant = variant}} data.forms["3|p|poss"] = {strong:make_form{grade = "strong", ending = "easẹt", variant = variant}} end end postprocess(args, data) return make_table(data) end

function export.contr(frame) local fparams = { [1] = {required = true}, ["nograd"] = {type = "boolean"}, }	local fargs = require("Module:parameters").process(frame.args, fparams) local params = { [1] = {default = mw.title.getCurrentTitle.nsText == "Template" and "" or ""}, ["attr"] = fargs[1] == "adjectives" and {list = true} or nil, ["n"] = fargs[1] == "nouns" and {} or nil, ["poss"] = fargs[1] == "nouns" and {} or nil, ["Q31"] = not fargs["nograd"] and {type = "boolean"} or nil, }	local args = require("Module:parameters").process(frame:getParent.args, params) local strong = require("Module:se-common").Stem(args[1], args["Q31"] and "Q31" or not fargs["nograd"], args["final"]) local weak = require("Module:se-common").Stem(args[1], args["Q31"] and "Q31" or not fargs["nograd"], args["final"]) strong.ucons = "" -- final consonant is lost in the strong grade local data = { has_attr = fargs[1] == "adjectives", has_poss = fargs[1] == "nouns" and not args["poss"], forms = {}, info = "contracted " .. require("Module:links").full_link({lang = lang, alt = strong.uvowel}, "term") .. "-stem", categories = {}, }	if strong.gradation then data.info = data.info .. ", " ..			require("Module:links").full_link({lang = lang, alt = strong.gradation.strong.scons}, "term") .. "-" ..			require("Module:links").full_link({lang = lang, alt = strong.gradation.weak.scons}, "term") .. " gradation" else data.info = data.info .. ", no gradation" end if not mw.ustring.find(strong.uvowel, "^[aáiou]$") and mw.title.getCurrentTitle.nsText ~= "Template" then error("The final vowel(s) of the stem must be one of a, á, i, o, u.") end if fargs[1] == "nouns" and args["poss"] and args["poss"] ~= "-" then local poss = possessives[args["poss"]:gsub("_", "|")] data.forms["nom|s"] = {strong:make_form{grade = "strong", ending = poss.even, variant = "contr_noun"}} data.forms["acc|s"] = {strong:make_form{grade = "strong", ending = poss.even, variant = "contr_noun"}} data.forms["gen|s"] = {strong:make_form{grade = "strong", ending = poss.even, variant = "contr_noun"}} data.forms["ill|s"] = {strong:make_form{grade = "strong", ending = "s" .. poss.odd, variant = "contr_noun"}} data.forms["loc|s"] = {strong:make_form{grade = "strong", ending = "st" .. poss.odd, variant = "contr_noun"}} data.forms["com|s"] = {strong:make_form{grade = "strong", ending = "in" .. poss.odd, variant = "contr_noun_j"}} data.forms["nom|p"] = nil data.forms["acc|p"] = {strong:make_form{grade = "strong", ending = "id" .. poss.odd, variant = "contr_noun_j"}} data.forms["gen|p"] = {strong:make_form{grade = "strong", ending = "id" .. poss.odd, variant = "contr_noun_j"}} data.forms["ill|p"] = {strong:make_form{grade = "strong", ending = "idasa" .. poss.even, variant = "contr_noun_j"}} data.forms["loc|p"] = {strong:make_form{grade = "strong", ending = "in" .. poss.odd, variant = "contr_noun_j"}} data.forms["com|p"] = {strong:make_form{grade = "strong", ending = "id" .. poss.odd .. "guin", variant = "contr_noun_j"}} data.forms["ess"]   = {weak:make_form{grade = "weak", ending = (weak.ucons == "" and "" or "i") .. "n" .. (weak.ucons == "" and poss.odd or "i" .. poss.even)}} else table.insert(data.categories, lang:getCanonicalName .. " contracted " .. fargs[1]) table.insert(data.categories, lang:getCanonicalName .. " contracted " .. (strong.uvowel or "") .. "-stem " .. fargs[1]) data.forms["nom|s"] = {weak:make_form{grade = "weak"}} data.forms["acc|s"] = {strong:make_form{grade = "strong", variant = "contr_noun"}} data.forms["gen|s"] = {strong:make_form{grade = "strong", variant = "contr_noun"}} data.forms["ill|s"] = {strong:make_form{grade = "strong", ending = "i", variant = "contr_noun_j"}} data.forms["loc|s"] = {strong:make_form{grade = "strong", ending = "s", variant = "contr_noun"}} data.forms["com|s"] = {strong:make_form{grade = "strong", ending = "in", variant = "contr_noun_j"}} data.forms["nom|p"] = {strong:make_form{grade = "strong", ending = "t", variant = "contr_noun"}} data.forms["acc|p"] = {strong:make_form{grade = "strong", ending = "id", variant = "contr_noun_j"}} data.forms["gen|p"] = {strong:make_form{grade = "strong", ending = "id", variant = "contr_noun_j"}} data.forms["ill|p"] = {strong:make_form{grade = "strong", ending = "ide", variant = "contr_noun_j"}} data.forms["loc|p"] = {strong:make_form{grade = "strong", ending = "in", variant = "contr_noun_j"}} data.forms["com|p"] = {strong:make_form{grade = "strong", ending = "iguin", variant = "contr_noun_j"}} data.forms["ess"]   = {weak:make_form{grade = "weak", ending = (weak.ucons == "" and "" or "i") .. "n"}} if fargs[1] == "nouns" then data.forms["1|s|poss"] = {strong:make_form{grade = "strong", ending = "n", variant = "contr_noun"}} data.forms["2|s|poss"] = {strong:make_form{grade = "strong", ending = "t", variant = "contr_noun"}} data.forms["3|s|poss"] = {strong:make_form{grade = "strong", ending = "s", variant = "contr_noun"}} data.forms["1|d|poss"] = {strong:make_form{grade = "strong", ending = "me", variant = "contr_noun"}} data.forms["2|d|poss"] = {strong:make_form{grade = "strong", ending = "de", variant = "contr_noun"}} data.forms["3|d|poss"] = {strong:make_form{grade = "strong", ending = "ska", variant = "contr_noun"}} data.forms["1|p|poss"] = {strong:make_form{grade = "strong", ending = "met", variant = "contr_noun"}} data.forms["2|p|poss"] = {strong:make_form{grade = "strong", ending = "det", variant = "contr_noun"}} data.forms["3|p|poss"] = {strong:make_form{grade = "strong", ending = "set", variant = "contr_noun"}} end end postprocess(args, data) return make_table(data) end

function export.even_comp(frame) local params = { [1] = {required = true, default = ""}, ["attr"] = {list = true}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local data = { has_attr = true, forms = {}, info = "", categories = {}, }	data.info = "even " .. require("Module:links").full_link({lang = lang, alt = "o"}, "term") .. "-stem" data.info = data.info .. require("Module:links").full_link({lang = lang, alt = "bb"}, "term") .. "-" .. require("Module:links").full_link({lang = lang, alt = "pp"}, "term") .. " gradation" table.insert(data.categories, lang:getCanonicalName .. " even adjectives") table.insert(data.categories, lang:getCanonicalName .. " even o-stem adjectives") data.forms["nom|s"] = {args[1] .. "it", args[1] .. "et"} data.forms["acc|s"] = {args[1] .. "eappọ"} data.forms["gen|s"] = {args[1] .. "eappọ"} data.forms["ill|s"] = {args[1] .. "ēbbui"} data.forms["loc|s"] = {args[1] .. "eappọs"} data.forms["com|s"] = {args[1] .. "eappuin"} data.forms["nom|p"] = {args[1] .. "eappọt"} data.forms["acc|p"] = {args[1] .. "eappuid"} data.forms["gen|p"] = {args[1] .. "eappuid"} data.forms["ill|p"] = {args[1] .. "eappuide"} data.forms["loc|p"] = {args[1] .. "eappuin"} data.forms["com|p"] = {args[1] .. "eappuiguin"} data.forms["ess"] = {args[1] .. "eabbọn"} postprocess(args, data) return make_table(data) end

function export.odd_comp(frame) local params = { [1] = {required = true, default = ""}, ["attr"] = {list = true}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local data = { has_attr = true, forms = {}, info = "", categories = {}, }	data.info = "odd " .. require("Module:links").full_link({lang = lang, alt = "u"}, "term") .. "-stem, no gradation" table.insert(data.categories, lang:getCanonicalName .. " odd adjectives") table.insert(data.categories, lang:getCanonicalName .. " non-gradating odd adjectives") data.forms["nom|s"] = {args[1] .. "t"} data.forms["acc|s"] = {args[1] .. "bu"} data.forms["gen|s"] = {args[1] .. "bu"} data.forms["ill|s"] = {args[1] .. "bui"} data.forms["loc|s"] = {args[1] .. "bus"} data.forms["com|s"] = {args[1] .. "buin"} data.forms["nom|p"] = {args[1] .. "but"} data.forms["acc|p"] = {args[1] .. "buid"} data.forms["gen|p"] = {args[1] .. "buid"} data.forms["ill|p"] = {args[1] .. "buidda"} data.forms["loc|p"] = {args[1] .. "buin"} data.forms["com|p"] = {args[1] .. "buiguin"} data.forms["ess"] = {args[1] .. "bun"} postprocess(args, data) return make_table(data) end

function export.dem(frame) local params = { [1] = {required = true, default = "dat"}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local data = { forms = {}, info = "", categories = {}, }	data.info = "pronominal inflection" local stem if args[1] == "gii" then stem = "gea" elseif args[1] == "mii" then stem = "ma" elseif mw.ustring.sub(args[1], -1) == "t" then stem = mw.ustring.sub(args[1], 1, -2) else error("Invalid pronoun.") end data.forms["nom|s"] = {args[1]} data.forms["acc|s"] = {stem .. "n"} data.forms["gen|s"] = {stem .. "n"} data.forms["ill|s"] = {stem .. "sa"} data.forms["loc|s"] = {stem .. "s"} data.forms["com|s"] = {stem .. "inna"} data.forms["nom|p"] = {stem .. "t"} data.forms["acc|p"] = {stem .. "id"} data.forms["gen|p"] = {stem .. "id"} data.forms["ill|p"] = {stem .. "idda"} data.forms["loc|p"] = {stem .. "in"} data.forms["com|p"] = {stem .. "iguin"} data.forms["ess"] = {stem .. "nin"} if args[1] == "mii" then table.insert(data.forms["acc|s"], "máid") end postprocess(args, data) return make_table(data) end

export["ieš"] = function(frame) local params = { ["poss"] = {}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local data = { has_poss = true, forms = {}, info = "irregular, suppletive", categories = {}, }	if args["poss"] then local poss = possessives[args["poss"]:gsub("_", "|")] data.forms["acc|s"] = {"ieža" .. poss.even, mw.ustring.find(args["poss"], "1") and "iehča" .. poss.even or nil} data.forms["gen|s"] = {"ieža" .. poss.even, mw.ustring.find(args["poss"], "1") and "iehča" .. poss.even or nil} data.forms["ill|s"] = {"alcces" .. poss.odd, "alcce" .. poss.even} data.forms["loc|s"] = {"aldd" .. (mw.ustring.find(args["poss"], "3") and "i" or "á") .. poss.even, not mw.ustring.find(args["poss"], "sg") and "alddiin" .. poss.odd or nil} data.forms["com|s"] = {"iežain" .. poss.odd} data.forms["ess"]   = {"iehčan" .. poss.odd} else data.forms["nom|s"] = {"ieš"} data.forms["nom|p"] = {"ieža"} data.forms["1|s|poss"] = {"iežan"} data.forms["2|s|poss"] = {"iežat"} data.forms["3|s|poss"] = {"iežas"} data.forms["1|d|poss"] = {"iežame"} data.forms["2|d|poss"] = {"iežade"} data.forms["3|d|poss"] = {"iežaska"} data.forms["1|p|poss"] = {"iežamet"} data.forms["2|p|poss"] = {"iežadet"} data.forms["3|p|poss"] = {"iežaset"} end postprocess(args, data) return make_table(data) end

function postprocess(args, data) if args["poss"] then data.has_poss = false end 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 .. " uncountable nouns") 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 if data.has_attr then if not args["attr"][1] then data.forms["attr"] = mw.clone(data.forms["nom|s"]) elseif args["attr"][1] ~= "-" then data.forms["attr"] = args["attr"] end end data.lemma = (data.forms["nom|" .. (data.n or "s")] or data.forms["acc|" .. (data.n or "s")])[1] -- Check if the lemma form matches the page name if (lang:makeEntryName(data.lemma)) ~= mw.title.getCurrentTitle.text then table.insert(data.categories, lang:getCanonicalName .. " entries with inflection not matching pagename") end end

-- Make the table function make_table(data) local function repl(param) local accel = true local no_store = false if param == "info" then return mw.getContentLanguage:ucfirst(data.info or "") elseif string.sub(param, 1, 1) == "!" then no_store = true param = string.sub(param, 2) elseif string.sub(param, 1, 1) == "#" then accel = false param = string.sub(param, 2) 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, term = subform, accel = accel and {form = param, no_store = no_store} or nil})) end return table.concat(ret, " ") end local wikicode = {} table.insert(wikicode, [=[ {| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="border:solid 1px #CCCCFF; text-align: left;" cellspacing="1" cellpadding="2" ! class="vsToggleElement" colspan="3" | ]=])
 * - style="background: #E2F6E2; text-align: left;"

if data.has_attr then table.insert(wikicode, [=[

! style="background: #E2F6E2;" | Attributive end table.insert(wikicode, [=[
 * - class="vsShow" style="background: #F2F2FF;"
 * colspan="2" | ]=])

! style="width: 8em; background: #E2F6E2;" | Nominative ! style="background: #E2F6E2;" | Genitive if data.has_attr then table.insert(wikicode, [=[
 * - class="vsShow" style="background: #F2F2FF;"
 * style="width: 15em;" colspan="2" |
 * - class="vsShow" style="background: #F2F2FF;"
 * colspan="2" | ]=])

! style="background: #E2F6E2;" | Attributive ]=])	end	table.insert(wikicode, [=[
 * - class="vsHide" style="background: #F2F2FF;"
 * colspan="2" |

! style="width: 8em; background: #C0E4C0;" | ! style="width: 12em; background: #C0E4C0;" | Singular ! style="width: 12em; background: #C0E4C0;" | Plural ! style="background: #E2F6E2;" | Nominative ! style="background: #E2F6E2;" | Accusative ! style="background: #E2F6E2;" | Genitive ! style="background: #E2F6E2;" | Illative ! style="background: #E2F6E2;" | Locative ! style="background: #E2F6E2;" | Comitative ! style="background: #E2F6E2;" | Essive -- Possessive forms if data.has_poss then table.insert(wikicode, [=[
 * - class="vsHide"
 * - class="vsHide" style="background: #F2F2FF;"
 * data-accel-col="1" |
 * data-accel-col="2" |
 * - class="vsHide" style="background: #F2F2FF;"
 * data-accel-col="1" |
 * data-accel-col="2" |
 * - class="vsHide" style="background: #F2F2FF;"
 * data-accel-col="1" |
 * data-accel-col="2" |
 * - class="vsHide" style="background: #F2F2FF;"
 * data-accel-col="1" |
 * data-accel-col="2" |
 * - class="vsHide" style="background: #F2F2FF;"
 * data-accel-col="1" |
 * data-accel-col="2" |
 * - class="vsHide" style="background: #F2F2FF;"
 * data-accel-col="1" |
 * data-accel-col="2" |
 * - class="vsHide" style="background: #F2F2FF;"
 * colspan="2" | ]=])

end table.insert(wikicode, "\n|}") return mw.ustring.gsub(table.concat(wikicode), "", repl) .. require("Module:utilities").format_categories(data.categories, lang) end
 * - class="vsHide"
 * colspan="3" style="padding: 0;" |

return export