Module:sma-verbs

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

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:sma-common").Stem(args[1]) local data = { forms = {}, info = "even " .. require("Module:links").full_link({lang = lang, alt = stem.uvowel}, "term") .. "-stem", categories = {}, }	if not (mw.ustring.find(stem.uvowel, "^[aeiu]$") or stem.uvowel == "ie" or stem.uvowel == "oe") and mw.title.getCurrentTitle.nsText ~= "Template" then error("The final vowel(s) of the stem must be one of a, e, i, u, ie, oe.") 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{ending = "dh", variant = "normal3"}} data.forms["past|ptcp"] = {stem:make_form{ending = "me", variant = "e3"}} data.forms["conn"]     = {stem:make_form{ending = "h", variant = "h"}} data.forms["1|s|pres|indc"] = {stem:make_form{ending = "m", variant = "pres_1sg"}} data.forms["2|s|pres|indc"] = {stem:make_form{ending = "h", variant = "pres_2sg"}} data.forms["3|s|pres|indc"] = {stem:make_form{variant = "pres_3sg"}} data.forms["1|d|pres|indc"] = {stem:make_form{ending = "n", variant = "pres_1du_3pl"}} data.forms["2|d|pres|indc"] = {stem:make_form{ending = "den", variant = "normal3"}, stem:make_form{ending = "jidien", variant = "jV"}} data.forms["3|d|pres|indc"] = {stem:make_form{ending = "jægan", variant = "jV"}} data.forms["1|p|pres|indc"] = {stem:make_form{ending = "be", variant = "normal3"}, stem:make_form{ending = "jibie", variant = "jV"}} data.forms["2|p|pres|indc"] = {stem:make_form{ending = "de", variant = "normal3"}, stem:make_form{ending = "jidie", variant = "jV"}} data.forms["3|p|pres|indc"] = {stem:make_form{ending = "h", variant = "pres_1du_3pl"}} data.forms["1|s|past|indc"] = {stem:make_form{ending = "jim", variant = "j"}, stem:make_form{ending = "jim", variant = "j_I"}} data.forms["2|s|past|indc"] = {stem:make_form{ending = "jih", variant = "j"}, stem:make_form{ending = "jih", variant = "j_I"}} data.forms["3|s|past|indc"] = {stem:make_form{ending = "ji", variant = "j"}, stem:make_form{ending = "ji", variant = "j_I"}} data.forms["1|d|past|indc"] = {stem:make_form{ending = "jimen", variant = "j"}, stem:make_form{ending = "jimen", variant = "j_I"}} data.forms["2|d|past|indc"] = {stem:make_form{ending = "jiden", variant = "j"}, stem:make_form{ending = "jiden", variant = "j_I"}} data.forms["3|d|past|indc"] = {stem:make_form{ending = "jigan", variant = "j"}, stem:make_form{ending = "jigan", variant = "j_I"}} data.forms["1|p|past|indc"] = {stem:make_form{ending = "jimh", variant = "j"}, stem:make_form{ending = "jimh", variant = "j_I"}} data.forms["2|p|past|indc"] = {stem:make_form{ending = "jidh", variant = "j"}, stem:make_form{ending = "jidh", variant = "j_I"}} data.forms["3|p|past|indc"] = {stem:make_form{ending = "jin", variant = "j"}, stem:make_form{ending = "jin", variant = "j_I"}} data.forms["2|s|impr"] = {stem:make_form{ending = "h", variant = "h"}} data.forms["2|d|impr"] = {stem:make_form{ending = "den", variant = "normal3"}, stem:make_form{ending = "jidien", variant = "jV"}} data.forms["2|p|impr"] = {stem:make_form{ending = "de", variant = "normal3"}, stem:make_form{ending = "jidie", variant = "jV"}}

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:sma-common").Stem(args[1]) local data = { forms = {}, info = "odd", 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 = "idh"}} data.forms["past|ptcp"] = {stem:make_form{ending = "amme"}} data.forms["conn"]     = {stem:make_form{ending = "h", variant = "normal3"}} data.forms["1|s|pres|indc"] = {stem:make_form{ending = "em", variant = "normal3"}} data.forms["2|s|pres|indc"] = {stem:make_form{ending = "h", variant = "normal3"}} data.forms["3|s|pres|indc"] = {stem:make_form{ending = "e", variant = "normal3"}} data.forms["1|d|pres|indc"] = {stem:make_form{ending = "ien"}} data.forms["2|d|pres|indc"] = {stem:make_form{ending = "idien"}} data.forms["3|d|pres|indc"] = {stem:make_form{ending = "ægan"}} data.forms["1|p|pres|indc"] = {stem:make_form{ending = "ibie"}} data.forms["2|p|pres|indc"] = {stem:make_form{ending = "idie"}} data.forms["3|p|pres|indc"] = {stem:make_form{ending = "ieh"}} data.forms["1|s|past|indc"] = {stem:make_form{ending = "im"}} data.forms["2|s|past|indc"] = {stem:make_form{ending = "ih"}} data.forms["3|s|past|indc"] = {stem:make_form{ending = "i"}} data.forms["1|d|past|indc"] = {stem:make_form{ending = "imen"}} data.forms["2|d|past|indc"] = {stem:make_form{ending = "iden"}} data.forms["3|d|past|indc"] = {stem:make_form{ending = "igan"}} data.forms["1|p|past|indc"] = {stem:make_form{ending = "imh"}} data.forms["2|p|past|indc"] = {stem:make_form{ending = "idh"}} data.forms["3|p|past|indc"] = {stem:make_form{ending = "in"}} data.forms["2|s|impr"] = {stem:make_form{ending = "h", variant = "normal3"}} data.forms["2|d|impr"] = {stem:make_form{ending = "idien"}} data.forms["2|p|impr"] = {stem:make_form{ending = "idie"}} postprocess(args, data) return make_table(data) end

function postprocess(args, data) for key, forms in pairs(data.forms) do		-- Remove duplicate forms forms = require("Module:table").removeDuplicates(forms) data.forms[key] = forms end 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