Module:smj-verbs

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

local export = {}

-- Inflection functions

function export.even(frame) local fparams = { ["nograd"] = {type = "boolean"}, }	local fargs = require("Module:parameters").process(frame.args, fparams) local params = { [1] = {required = true, default = ""}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local stem = require("Module:smj-common").Stem(args[1], not fargs["nograd"]) local data = { 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 not mw.ustring.find(stem.uvowel, "^[aeoå]$") and mw.title.getCurrentTitle.nsText ~= "Template" then error("The final vowel(s) of the stem must be one of a, e, o, å.") end table.insert(data.categories, lang:getCanonicalName .. " even verbs") table.insert(data.categories, lang:getCanonicalName .. " even " .. (stem.uvowel or "") .. "-stem verbs") data.forms["inf"]      = {stem:make_form{grade = "strong", ending = "t"}} data.forms["pres|ptcp"] = {stem:make_form{grade = "extra", variant = "j_contr_final"}} data.forms["past|ptcp"] = {stem:make_form{grade = "strong", ending = "m", variant = "e"}} data.forms["1|s|pres|indc"] = {stem:make_form{grade = "weak", ending = "v", variant = "pres_12sg"}} data.forms["2|s|pres|indc"] = {stem:make_form{grade = "weak", variant = "pres_12sg"}} data.forms["3|s|pres|indc"] = {stem:make_form{grade = "strong", variant = "pres_3sg"}} data.forms["1|d|pres|indc"] = {stem:make_form{grade = "strong", ending = "n", variant = "j_contr"}} data.forms["2|d|pres|indc"] = {stem:make_form{grade = "strong", ending = "bihtte"}} data.forms["3|d|pres|indc"] = {stem:make_form{grade = "strong", ending = "ba"}} data.forms["1|p|pres|indc"] = {stem:make_form{grade = "strong", ending = "p"}} data.forms["2|p|pres|indc"] = {stem:make_form{grade = "strong", ending = "bihtit"}} data.forms["3|p|pres|indc"] = {stem:make_form{grade = "strong", variant = "j_contr"}} data.forms["indc|conn"] = {stem:make_form{grade = "weak"}} data.forms["1|s|past|indc"] = {stem:make_form{grade = "strong", ending = "v", variant = "j_contr"}} data.forms["2|s|past|indc"] = {stem:make_form{grade = "strong", variant = "j_contr"}} data.forms["3|s|past|indc"] = {stem:make_form{grade = "weak", ending = "j", variant = "j"}} data.forms["1|d|past|indc"] = {stem:make_form{grade = "weak", ending = "jma", variant = "j"}} data.forms["2|d|past|indc"] = {stem:make_form{grade = "weak", ending = "jda", variant = "j"}} data.forms["3|d|past|indc"] = {stem:make_form{grade = "weak", ending = "jga", variant = "j"}} data.forms["1|p|past|indc"] = {stem:make_form{grade = "weak", ending = "jma", variant = "j"}} data.forms["2|p|past|indc"] = {stem:make_form{grade = "weak", ending = "jda", variant = "j"}} data.forms["3|p|past|indc"] = {stem:make_form{grade = "strong", ending = "n", variant = "j_contr"}} data.forms["2|s|impr"] = {stem:make_form{grade = "weak"}} data.forms["3|s|impr"] = {stem:make_form{grade = "strong", ending = "s", variant = "j_contr"}} data.forms["1|d|impr"] = {stem:make_form{grade = "strong", ending = "n", variant = "impr"}} data.forms["2|d|impr"] = {stem:make_form{grade = "extra", variant = "j_contr_final"}} data.forms["3|d|impr"] = {stem:make_form{grade = "strong", ending = "ska", variant = "j_contr"}} data.forms["1|p|impr"] = {stem:make_form{grade = "strong", ending = "p", variant = "impr"}} data.forms["2|p|impr"] = {stem:make_form{grade = "strong", ending = "t", variant = "j_contr"}} data.forms["3|p|impr"] = {stem:make_form{grade = "strong", ending = "sa", variant = "j_contr"}} data.forms["impr|conn"] = {stem:make_form{grade = "weak"}} data.forms["1|s|cond"] = {stem:make_form{grade = "weak", ending = "luluv"}} data.forms["2|s|cond"] = {stem:make_form{grade = "weak", ending = "lulu"}} data.forms["3|s|cond"] = {stem:make_form{grade = "weak", ending = "luluj"}} data.forms["1|d|cond"] = {stem:make_form{grade = "weak", ending = "lulujma"}} data.forms["2|d|cond"] = {stem:make_form{grade = "weak", ending = "lulujda"}} data.forms["3|d|cond"] = {stem:make_form{grade = "weak", ending = "lulujga"}} data.forms["1|p|cond"] = {stem:make_form{grade = "weak", ending = "lulujma"}} data.forms["2|p|cond"] = {stem:make_form{grade = "weak", ending = "lulujda"}} data.forms["3|p|cond"] = {stem:make_form{grade = "weak", ending = "lulun"}} data.forms["cond|conn"] = {stem:make_form{grade = "weak", ending = "lulu"}} data.forms["1|s|potn"] = {stem:make_form{grade = "weak", ending = "tjav", variant = "i"}} data.forms["2|s|potn"] = {stem:make_form{grade = "weak", ending = "tja", variant = "i"}} data.forms["3|s|potn"] = {stem:make_form{grade = "weak", ending = "sj", variant = "i"}} data.forms["1|d|potn"] = {stem:make_form{grade = "weak", ending = "tjin", variant = "i"}} data.forms["2|d|potn"] = {stem:make_form{grade = "weak", ending = "tjihppe", variant = "i"}} data.forms["3|d|potn"] = {stem:make_form{grade = "weak", ending = "tjibá", variant = "i"}} data.forms["1|p|potn"] = {stem:make_form{grade = "weak", ending = "tjip", variant = "i"}} data.forms["2|p|potn"] = {stem:make_form{grade = "weak", ending = "tjihpit", variant = "i"}} data.forms["3|p|potn"] = {stem:make_form{grade = "weak", ending = "tji", variant = "i"}} data.forms["potn|conn"] = {stem:make_form{grade = "weak", ending = "tja", variant = "i"}} data.forms["2|s|opta"] = {stem:make_form{grade = "strong", variant = "opta"}} data.forms["3|s|opta"] = {stem:make_form{grade = "strong", ending = "s", variant = "opta"}} data.forms["1|d|opta"] = {stem:make_form{grade = "strong", ending = "n", variant = "opta"}} data.forms["2|d|opta"] = {stem:make_form{grade = "strong", ending = "da", variant = "opta"}} data.forms["3|d|opta"] = {stem:make_form{grade = "strong", ending = "ska", variant = "opta"}} data.forms["1|p|opta"] = {stem:make_form{grade = "strong", ending = "p", variant = "opta"}} data.forms["2|p|opta"] = {stem:make_form{grade = "strong", ending = "t", variant = "opta"}} data.forms["3|p|opta"] = {stem:make_form{grade = "strong", ending = "sa", variant = "opta"}} data.forms["opta|conn"] = {stem:make_form{grade = "strong", variant = "opta"}} postprocess(args, data) return make_table(data) end

function export.odd(frame) local fparams = { }	local fargs = require("Module:parameters").process(frame.args, fparams) local params = { [1] = {required = true, default = ""}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local stem = require("Module:smj-common").Stem(args[1]) local data = { forms = {}, info = "odd, no gradation", categories = {}, }	if stem.ucons == "" and mw.title.getCurrentTitle.nsText ~= "Template" then error("The stem must end in a consonant.") end table.insert(data.categories, lang:getCanonicalName .. " odd verbs") data.forms["inf"]      = {stem:make_form{ending = "it"}} data.forms["pres|ptcp"] = {stem:make_form{ending = "iddje"}} data.forms["past|ptcp"] = {stem:make_form{ending = "am"}} data.forms["1|s|pres|indc"] = {stem:make_form{ending = "av"}} data.forms["2|s|pres|indc"] = {stem:make_form{ending = "a"}} data.forms["3|s|pres|indc"] = {stem:make_form{}} data.forms["1|d|pres|indc"] = {stem:make_form{ending = "in"}} data.forms["2|d|pres|indc"] = {stem:make_form{ending = "ihppe"}} data.forms["3|d|pres|indc"] = {stem:make_form{ending = "ibá"}} data.forms["1|p|pres|indc"] = {stem:make_form{ending = "ip"}} data.forms["2|p|pres|indc"] = {stem:make_form{ending = "ihpit"}} data.forms["3|p|pres|indc"] = {stem:make_form{ending = "i"}} data.forms["indc|conn"] = {stem:make_form{ending = "a"}} data.forms["1|s|past|indc"] = {stem:make_form{ending = "iv"}} data.forms["2|s|past|indc"] = {stem:make_form{ending = "i"}} data.forms["3|s|past|indc"] = {stem:make_form{ending = "ij"}} data.forms["1|d|past|indc"] = {stem:make_form{ending = "ijma"}} data.forms["2|d|past|indc"] = {stem:make_form{ending = "ijda"}} data.forms["3|d|past|indc"] = {stem:make_form{ending = "ijga"}} data.forms["1|p|past|indc"] = {stem:make_form{ending = "ijma"}} data.forms["2|p|past|indc"] = {stem:make_form{ending = "ijda"}} data.forms["3|p|past|indc"] = {stem:make_form{ending = "in"}} data.forms["2|s|impr"] = {stem:make_form{ending = "a"}} data.forms["3|s|impr"] = {stem:make_form{ending = "is"}} data.forms["1|d|impr"] = {stem:make_form{ending = "inˈno"}} data.forms["2|d|impr"] = {stem:make_form{ending = "ihtte"}} data.forms["3|d|impr"] = {stem:make_form{ending = "iska"}} data.forms["1|p|impr"] = {stem:make_form{ending = "ip"}} data.forms["2|p|impr"] = {stem:make_form{ending = "ihtit"}} data.forms["3|p|impr"] = {stem:make_form{ending = "isá"}} data.forms["impr|conn"] = {stem:make_form{ending = "a"}} data.forms["1|s|cond"] = {stem:make_form{ending = "aluluv"}} data.forms["2|s|cond"] = {stem:make_form{ending = "alulu"}} data.forms["3|s|cond"] = {stem:make_form{ending = "aluluj"}} data.forms["1|d|cond"] = {stem:make_form{ending = "alulujma"}} data.forms["2|d|cond"] = {stem:make_form{ending = "alulujda"}} data.forms["3|d|cond"] = {stem:make_form{ending = "alulujga"}} data.forms["1|p|cond"] = {stem:make_form{ending = "alulujma"}} data.forms["2|p|cond"] = {stem:make_form{ending = "alulujda"}} data.forms["3|p|cond"] = {stem:make_form{ending = "alulun"}} data.forms["cond|conn"] = {stem:make_form{ending = "alulu"}} data.forms["1|s|potn"] = {stem:make_form{ending = "ittjav"}} data.forms["2|s|potn"] = {stem:make_form{ending = "ittja"}} data.forms["3|s|potn"] = {stem:make_form{ending = "isj"}} data.forms["1|d|potn"] = {stem:make_form{ending = "ittjin"}} data.forms["2|d|potn"] = {stem:make_form{ending = "ittjabihtte"}} data.forms["3|d|potn"] = {stem:make_form{ending = "ittjaba"}} data.forms["1|p|potn"] = {stem:make_form{ending = "ittjap"}} data.forms["2|p|potn"] = {stem:make_form{ending = "ittjabihtit"}} data.forms["3|p|potn"] = {stem:make_form{ending = "ittji"}} data.forms["potn|conn"] = {stem:make_form{ending = "ittja"}} data.forms["2|s|opta"] = {stem:make_form{ending = "u"}} data.forms["3|s|opta"] = {stem:make_form{ending = "us"}} data.forms["1|d|opta"] = {stem:make_form{ending = "unˈno"}} data.forms["2|d|opta"] = {stem:make_form{ending = "uhtuda"}} data.forms["3|d|opta"] = {stem:make_form{ending = "uska"}} data.forms["1|p|opta"] = {stem:make_form{ending = "up"}} data.forms["2|p|opta"] = {stem:make_form{ending = "uhtut"}} data.forms["3|p|opta"] = {stem:make_form{ending = "usá"}} data.forms["opta|conn"] = {stem:make_form{ending = "u"}} postprocess(args, data) return make_table(data) end

function export.contr(frame) local fparams = { }	local fargs = require("Module:parameters").process(frame.args, fparams) local params = { [1] = {required = true, default = ""}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local stem = require("Module:smj-common").Stem(args[1]) local data = { forms = {}, info = "contracted " .. require("Module:links").full_link({lang = lang, alt = stem.uvowel}, "term") .. "-stem, no gradation", categories = {}, }	if not (mw.ustring.find(stem.uvowel, "^[áiu]$") or stem.uvowel == "å̄") and mw.title.getCurrentTitle.nsText ~= "Template" then error("The final vowel(s) of the stem must be one of á, i, u, å̄.") end table.insert(data.categories, lang:getCanonicalName .. " contracted verbs") table.insert(data.categories, lang:getCanonicalName .. " contracted " .. (stem.uvowel or "") .. "-stem verbs") data.forms["inf"]      = {stem:make_form{ending = "t"}} data.forms["pres|ptcp"] = {stem:make_form{ending = "jiddje"}} data.forms["past|ptcp"] = {stem:make_form{ending = "m"}} data.forms["1|s|pres|indc"] = {stem:make_form{ending = "v"}} data.forms["2|s|pres|indc"] = {stem:make_form{}} data.forms["3|s|pres|indc"] = {stem:make_form{}} data.forms["1|d|pres|indc"] = {stem:make_form{ending = "jin"}} data.forms["2|d|pres|indc"] = {stem:make_form{ending = "bihtte"}} data.forms["3|d|pres|indc"] = {stem:make_form{ending = "ba"}} data.forms["1|p|pres|indc"] = {stem:make_form{ending = "p"}} data.forms["2|p|pres|indc"] = {stem:make_form{ending = "bihtit"}} data.forms["3|p|pres|indc"] = {stem:make_form{ending = "ji"}} data.forms["indc|conn"] = {stem:make_form{}} data.forms["1|s|past|indc"] = {stem:make_form{ending = "jiv"}} data.forms["2|s|past|indc"] = {stem:make_form{ending = "ji"}} data.forms["3|s|past|indc"] = {stem:make_form{ending = "j"}} data.forms["1|d|past|indc"] = {stem:make_form{ending = "jma"}} data.forms["2|d|past|indc"] = {stem:make_form{ending = "jda"}} data.forms["3|d|past|indc"] = {stem:make_form{ending = "jga"}} data.forms["1|p|past|indc"] = {stem:make_form{ending = "jma"}} data.forms["2|p|past|indc"] = {stem:make_form{ending = "jda"}} data.forms["3|p|past|indc"] = {stem:make_form{ending = "jin"}} data.forms["2|s|impr"] = {stem:make_form{}} data.forms["3|s|impr"] = {stem:make_form{ending = "jis"}} data.forms["1|d|impr"] = {stem:make_form{ending = "jinˈno"}} data.forms["2|d|impr"] = {stem:make_form{ending = "jihtte"}} data.forms["3|d|impr"] = {stem:make_form{ending = "jiska"}} data.forms["1|p|impr"] = {stem:make_form{ending = "jip"}} data.forms["2|p|impr"] = {stem:make_form{ending = "jihtit"}} data.forms["3|p|impr"] = {stem:make_form{ending = "jisá"}} data.forms["impr|conn"] = {stem:make_form{}} data.forms["1|s|cond"] = {stem:make_form{ending = "luluv"}} data.forms["2|s|cond"] = {stem:make_form{ending = "lulu"}} data.forms["3|s|cond"] = {stem:make_form{ending = "luluj"}} data.forms["1|d|cond"] = {stem:make_form{ending = "lulujma"}} data.forms["2|d|cond"] = {stem:make_form{ending = "lulujda"}} data.forms["3|d|cond"] = {stem:make_form{ending = "lulujga"}} data.forms["1|p|cond"] = {stem:make_form{ending = "lulujma"}} data.forms["2|p|cond"] = {stem:make_form{ending = "lulujda"}} data.forms["3|p|cond"] = {stem:make_form{ending = "lulun"}} data.forms["cond|conn"] = {stem:make_form{ending = "lulu"}} data.forms["1|s|potn"] = {stem:make_form{ending = "tjav"}} data.forms["2|s|potn"] = {stem:make_form{ending = "tja"}} data.forms["3|s|potn"] = {stem:make_form{ending = "sj"}} data.forms["1|d|potn"] = {stem:make_form{ending = "tjin"}} data.forms["2|d|potn"] = {stem:make_form{ending = "tjihppe"}} data.forms["3|d|potn"] = {stem:make_form{ending = "tjibá"}} data.forms["1|p|potn"] = {stem:make_form{ending = "tjip"}} data.forms["2|p|potn"] = {stem:make_form{ending = "tjihpit"}} data.forms["3|p|potn"] = {stem:make_form{ending = "tji"}} data.forms["potn|conn"] = {stem:make_form{ending = "tja"}} data.forms["2|s|opta"] = {stem:make_form{ending = "ju"}} data.forms["3|s|opta"] = {stem:make_form{ending = "jus"}} data.forms["1|d|opta"] = {stem:make_form{ending = "junˈno"}} data.forms["2|d|opta"] = {stem:make_form{ending = "juhtuda"}} data.forms["3|d|opta"] = {stem:make_form{ending = "juska"}} data.forms["1|p|opta"] = {stem:make_form{ending = "jup"}} data.forms["2|p|opta"] = {stem:make_form{ending = "juhtut"}} data.forms["3|p|opta"] = {stem:make_form{ending = "jusá"}} data.forms["opta|conn"] = {stem:make_form{ending = "ju"}} postprocess(args, data) return make_table(data) end

function postprocess(args, data) data.lemma = data.forms["inf"][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, lemma = data.lemma, no_store = no_store} or nil})) end return table.concat(ret, " ") end local wikicode = [=[

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

return export