Module:sms-verbs

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

local export = {}

-- Inflection functions

function export.even(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:sms-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 = "d"}} data.forms["pres|ptcp"] = {stem:make_form{grade = "strong", ending = "i", variant = "j0"}} data.forms["past|ptcp"] = {stem:make_form{grade = "strong", ending = "m", variant = "past_ptcp"}} data.forms["1|s|pres|indc"] = {stem:make_form{grade = "weak", ending = "m", variant = "pres_12sg"}} data.forms["2|s|pres|indc"] = {stem:make_form{grade = "weak", ending = "k", variant = "pres_12sg"}} data.forms["3|s|pres|indc"] = {stem:make_form{grade = "strong", variant = "pres_3sg_even"}} 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 = "veʹted", variant = "normal0"}} data.forms["3|p|pres|indc"] = {stem:make_form{grade = "extra", variant = "pres_3pl"}} data.forms["4|pres|indc"]  = {stem:make_form{grade = "weak", ending = "t"}} data.forms["pres|indc|conn"] = {stem:make_form{grade = "weak", variant = "normal0"}} data.forms["1|s|past|indc"] = {stem:make_form{grade = "extra", ending = "m", variant = "j_contr"}} data.forms["2|s|past|indc"] = {stem:make_form{grade = "extra", ending = stem.uvowel == "a" and "k" or "ǩ", variant = "j_contr2"}} data.forms["3|s|past|indc"] = {stem:make_form{grade = "weak", ending = "i", variant = "j0"}} data.forms["1|p|past|indc"] = {stem:make_form{grade = "weak", ending = "im", variant = "j0"}} data.forms["2|p|past|indc"] = {stem:make_form{grade = "weak", ending = "id", variant = "j0"}} data.forms["3|p|past|indc"] = {stem:make_form{grade = "extra", variant = "j_contr"}} data.forms["4|past|indc"]  = {stem:make_form{grade = "extra", ending = "š", variant = "j_contr"}} data.forms["past|indc|conn"] = {stem:make_form{grade = "strong", ending = "m", variant = "past_ptcp"}} data.forms["2|s|impr"] = {stem:make_form{grade = "weak", variant = "normal0"}} data.forms["3|s|impr"] = {stem:make_form{grade = "weak", ending = "s", variant = "impr"}} data.forms["1|p|impr"] = {stem:make_form{grade = "strong", ending = "p"}} data.forms["2|p|impr"] = {stem:make_form{grade = "strong", ending = "d"}} data.forms["3|p|impr"] = {stem:make_form{grade = "extra", ending = "z", variant = "impr"}} data.forms["impr|conn"] = {stem:make_form{grade = "weak", variant = "normal0"}} data.forms["1|s|cond"] = {stem:make_form{grade = "weak", ending = "čem", variant = "normal0"}} data.forms["2|s|cond"] = {stem:make_form{grade = "weak", ending = "čiǩ", variant = "normal0"}} data.forms["3|s|cond"] = {stem:make_form{grade = "weak", ending = "či", variant = "normal0"}} data.forms["1|p|cond"] = {stem:make_form{grade = "weak", ending = "čim", variant = "normal0"}} data.forms["2|p|cond"] = {stem:make_form{grade = "weak", ending = "čid", variant = "normal0"}} data.forms["3|p|cond"] = {stem:make_form{grade = "weak", ending = "če", variant = "normal0"}} data.forms["4|cond"]  = {stem:make_form{grade = "weak", ending = "češ", variant = "normal0"}} data.forms["cond|conn"] = {stem:make_form{grade = "weak", ending = "če", variant = "normal0"}} data.forms["1|s|potn"] = {stem:make_form{grade = "weak", ending = "žem", variant = "j0"}} data.forms["2|s|potn"] = {stem:make_form{grade = "weak", ending = "žiǩ", variant = "j0"}} data.forms["3|s|potn"] = {stem:make_form{grade = "weak", ending = "ž", variant = "j"}} data.forms["1|p|potn"] = {stem:make_form{grade = "weak", ending = "žep", variant = "j0"}} data.forms["2|p|potn"] = {stem:make_form{grade = "weak", ending = "žid", variant = "j0"}} data.forms["3|p|potn"] = {stem:make_form{grade = "weak", ending = "že", variant = "j0"}} data.forms["4|potn"]  = {stem:make_form{grade = "weak", ending = "žet", variant = "j0"}} data.forms["potn|conn"] = {stem:make_form{grade = "weak", ending = "že", variant = "j0"}} 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:sms-common").Stem(args[1]) local stem2 = require("Module:sms-common").Stem(args[1]) if stem.ucons == "ǥ" then stem.ucons = "j" elseif stem2.ucons == "j" then stem2.ucons = "" end local data = { forms = {}, info = "odd " .. require("Module:links").full_link({lang = lang, alt = stem.uvowel}, "term") .. "-stem, no gradation", categories = {}, }	table.insert(data.categories, lang:getCanonicalName .. " odd verbs") table.insert(data.categories, lang:getCanonicalName .. " odd " .. (stem.uvowel or "") .. "-stem verbs") data.forms["inf"]      = {stem:make_form{ending = "ed", variant = "normal0"}} data.forms["pres|ptcp"] = {stem:make_form{ending = "eei", variant = "normal0"}} data.forms["past|ptcp"] = {stem:make_form{ending = "am", variant = "normal0"}} data.forms["1|s|pres|indc"] = {stem:make_form{ending = "am", variant = "normal0"}} data.forms["2|s|pres|indc"] = {stem:make_form{ending = "ak", variant = "normal0"}} data.forms["3|s|pres|indc"] = {stem:make_form{variant = "pres_3sg_odd"}} data.forms["1|p|pres|indc"] = {stem:make_form{ending = "ep", variant = "normal0"}} data.forms["2|p|pres|indc"] = {stem:make_form{ending = "eʹped", variant = "normal0"}} data.forms["3|p|pres|indc"] = {stem:make_form{ending = "e", variant = "normal0"}} data.forms["4|pres|indc"]  = {stem:make_form{ending = "et", variant = "normal0"}} data.forms["pres|indc|conn"] = {stem2:make_form{variant = stem2.ucons == "" and "j_contr" or nil}} data.forms["1|s|past|indc"] = {stem:make_form{ending = "em", variant = "normal0"}} data.forms["2|s|past|indc"] = {stem:make_form{ending = "iǩ", variant = "normal0"}} data.forms["3|s|past|indc"] = {stem:make_form{ending = "i", variant = "normal0"}} data.forms["1|p|past|indc"] = {stem:make_form{ending = "im", variant = "normal0"}} data.forms["2|p|past|indc"] = {stem:make_form{ending = "id", variant = "normal0"}} data.forms["3|p|past|indc"] = {stem:make_form{ending = "e", variant = "normal0"}} data.forms["4|past|indc"]  = {stem:make_form{ending = "eš", variant = "normal0"}} data.forms["past|indc|conn"] = {stem:make_form{ending = "am", variant = "normal0"}} data.forms["2|s|impr"] = {stem2:make_form{variant = stem2.ucons == "" and "j_contr" or nil}} data.forms["3|s|impr"] = {stem:make_form{ending = "ââǥǥas", variant = "normal0"}} data.forms["1|p|impr"] = {stem:make_form{ending = "âkap", variant = "normal0"}} data.forms["2|p|impr"] = {stem:make_form{ending = "eʹǩed", variant = "normal0"}} data.forms["3|p|impr"] = {stem:make_form{ending = "âkaz", variant = "normal0"}} data.forms["impr|conn"] = {stem2:make_form{variant = stem2.ucons == "" and "j_contr" or nil}} data.forms["1|s|cond"] = {stem:make_form{ending = "eʹčem", variant = "normal0"}} data.forms["2|s|cond"] = {stem:make_form{ending = "eʹčiǩ", variant = "normal0"}} data.forms["3|s|cond"] = {stem:make_form{ending = "eʹči", variant = "normal0"}} data.forms["1|p|cond"] = {stem:make_form{ending = "eʹčim", variant = "normal0"}} data.forms["2|p|cond"] = {stem:make_form{ending = "eʹčid", variant = "normal0"}} data.forms["3|p|cond"] = {stem:make_form{ending = "eʹče", variant = "normal0"}} data.forms["4|cond"]  = {stem:make_form{ending = "eʹčeš", variant = "normal0"}} data.forms["cond|conn"] = {stem:make_form{ending = "eʹče", variant = "normal0"}} data.forms["1|s|potn"] = {stem:make_form{ending = "eʹžem", variant = "normal0"}} data.forms["2|s|potn"] = {stem:make_form{ending = "eʹžiǩ", variant = "normal0"}} data.forms["3|s|potn"] = {stem:make_form{ending = "ež", variant = "normal0"}} data.forms["1|p|potn"] = {stem:make_form{ending = "eʹžep", variant = "normal0"}} data.forms["2|p|potn"] = {stem:make_form{ending = "eʹžid", variant = "normal0"}} data.forms["3|p|potn"] = {stem:make_form{ending = "eʹže", variant = "normal0"}} data.forms["4|potn"]  = {stem:make_form{ending = "eʹžet", variant = "normal0"}} data.forms["potn|conn"] = {stem:make_form{ending = "eʹže", variant = "normal0"}} 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:sms-common").Stem(args[1]) local data = { forms = {}, info = "contracted " .. require("Module:links").full_link({lang = lang, alt = stem.uvowel}, "term") .. "-stem, no gradation", categories = {}, }	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 = "eed", variant = "normal0"}} data.forms["pres|ptcp"] = {stem:make_form{ending = "eei", variant = "normal0"}} data.forms["past|ptcp"] = {stem:make_form{ending = "ääm", variant = "normal0"}} data.forms["1|s|pres|indc"] = {stem:make_form{ending = "ääm", variant = "normal0"}} data.forms["2|s|pres|indc"] = {stem:make_form{ending = "ääk", variant = "normal0"}} data.forms["3|s|pres|indc"] = {stem:make_form{ending = "ad", variant = "normal0"}} data.forms["1|p|pres|indc"] = {stem:make_form{ending = "eep", variant = "normal0"}} data.forms["2|p|pres|indc"] = {stem:make_form{ending = "eʹped", variant = "normal0"}} data.forms["3|p|pres|indc"] = {stem:make_form{ending = "ee", variant = "normal0"}} data.forms["4|pres|indc"]  = {stem:make_form{ending = "eet", variant = "normal0"}} data.forms["pres|indc|conn"] = {stem:make_form{ending = "d"}} data.forms["1|s|past|indc"] = {stem:make_form{ending = "eem", variant = "normal0"}} data.forms["2|s|past|indc"] = {stem:make_form{ending = "iiǩ", variant = "normal0"}} data.forms["3|s|past|indc"] = {stem:make_form{ending = "ii", variant = "normal0"}} data.forms["1|p|past|indc"] = {stem:make_form{ending = "iim", variant = "normal0"}} data.forms["2|p|past|indc"] = {stem:make_form{ending = "iid", variant = "normal0"}} data.forms["3|p|past|indc"] = {stem:make_form{ending = "ee", variant = "normal0"}} data.forms["4|past|indc"]  = {stem:make_form{ending = "eeš", variant = "normal0"}} data.forms["past|indc|conn"] = {stem:make_form{ending = "ääm", variant = "normal0"}} data.forms["2|s|impr"] = {stem:make_form{ending = "d"}} data.forms["3|s|impr"] = {stem:make_form{ending = "ââǥǥas", variant = "normal0"}} data.forms["1|p|impr"] = {stem:make_form{ending = "âkap", variant = "normal0"}} data.forms["2|p|impr"] = {stem:make_form{ending = "eʹǩed", variant = "normal0"}} data.forms["3|p|impr"] = {stem:make_form{ending = "âkaz", variant = "normal0"}} data.forms["impr|conn"] = {stem:make_form{ending = "d"}} data.forms["1|s|cond"] = {stem:make_form{ending = "eʹčem", variant = "normal0"}} data.forms["2|s|cond"] = {stem:make_form{ending = "eʹčiǩ", variant = "normal0"}} data.forms["3|s|cond"] = {stem:make_form{ending = "eʹči", variant = "normal0"}} data.forms["1|p|cond"] = {stem:make_form{ending = "eʹčim", variant = "normal0"}} data.forms["2|p|cond"] = {stem:make_form{ending = "eʹčid", variant = "normal0"}} data.forms["3|p|cond"] = {stem:make_form{ending = "eʹče", variant = "normal0"}} data.forms["4|cond"]  = {stem:make_form{ending = "eʹčeš", variant = "normal0"}} data.forms["cond|conn"] = {stem:make_form{ending = "eʹče", variant = "normal0"}} data.forms["1|s|potn"] = {stem:make_form{ending = "eʹžem", variant = "normal0"}} data.forms["2|s|potn"] = {stem:make_form{ending = "eʹžiǩ", variant = "normal0"}} data.forms["3|s|potn"] = {stem:make_form{ending = "ež", variant = "normal0"}} data.forms["1|p|potn"] = {stem:make_form{ending = "eʹžep", variant = "normal0"}} data.forms["2|p|potn"] = {stem:make_form{ending = "eʹžid", variant = "normal0"}} data.forms["3|p|potn"] = {stem:make_form{ending = "eʹže", variant = "normal0"}} data.forms["4|potn"]  = {stem:make_form{ending = "eʹžet", variant = "normal0"}} data.forms["potn|conn"] = {stem:make_form{ending = "eʹže", variant = "normal0"}} 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