Module:Mhy-verbs

local m_utilities = require("Module:utilities") local m_links = require("Module:links")

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

local export = {}

-- Functions that do the actual inflecting by creating the forms of a basic term. local inflections = {}

-- The main entry point. -- This is the only function that can be invoked from a template. function export.show(frame) local infl_type = frame.args[1] or error("Inflection type has not been specified. Please pass parameter 1 to the module invocation") local args = frame:getParent.args if not inflections[infl_type] then error("Unknown inflection type '" .. infl_type .. "'") end local data = {forms = {}, title = nil, categories = {}} -- Generate the forms inflections[infl_type](args, data) -- Postprocess postprocess(args, data) if args["type"] then table.insert(data.categories, "mhy-conj with type") end return make_table(data) .. m_utilities.format_categories(data.categories, lang) end

-- Get parameters from the template, in standard order and numbering local function get_params(args, num) local params = {} if num == 4 then params.base = args[1] or (mw.title.getCurrentTitle.nsText == "Template" and ""); if not params.base or params.base == "" then error("Parameter 1 (base stem) may not be empty.") end params.strong = args[2] or (mw.title.getCurrentTitle.nsText == "Template" and "") or "" params.weak = args[3] or (mw.title.getCurrentTitle.nsText == "Template" and "") or "" params.final = args[4] or (mw.title.getCurrentTitle.nsText == "Template" and ""); if not params.final or params.final == "" then error("Parameter 4 (final letter(s)) may not be empty.") end elseif num == 3 then params.base = args[1] or (mw.title.getCurrentTitle.nsText == "Template" and ""); if not params.base or params.base == "" then error("Parameter 1 (base stem) may not be empty.") end params.strong = args[2] or (mw.title.getCurrentTitle.nsText == "Template" and "") or "" params.weak = args[3] or (mw.title.getCurrentTitle.nsText == "Template" and "") or "" elseif num == 1 then params.base = args[1] or (mw.title.getCurrentTitle.nsText == "Template" and ""); if not params.base or params.base == "" then error("Parameter 1 (base stem) may not be empty.") end end return params end

-- Inflection functions

local stem_endings = {}

stem_endings["ma_inf"] = { ["ma_inf"] = "ma", ["ma_inf_ine"] = "mas", ["ma_inf_ela"] = "mast", ["ma_inf_tra"] = "maks", ["ma_inf_abe"] = "mata", ["quot"] = "vat", }

stem_endings["da_inf"] = { ["da_inf"] = "a", ["des_inf"] = "es", }

stem_endings["pres"] = { ["pres_1sg"] = "n", ["pres_2sg"] = "d", ["pres_3sg"] = "b", ["pres_1pl"] = "me", ["pres_2pl"] = "te", ["pres_3pl"] = "vad", ["pres_conn"] = "", ["cond_1sg"] = "ksin", ["cond_2sg"] = "ksid", ["cond_3sg"] = "ks", ["cond_1pl"] = "ksime", ["cond_2pl"] = "ksite", ["cond_3pl"] = "ksid", ["cond_conn"] = "ks", ["impr_2sg"] = "", }

stem_endings["past"] = { ["past_1sg"] = "n", ["past_2sg"] = "d", ["past_1pl"] = "me", ["past_2pl"] = "te", ["past_3pl"] = "d", }

stem_endings["past_3sg"] = { ["past_3sg"] = "", }

stem_endings["impr"] = { ["impr_3sg"] = "u", ["impr_1pl"] = "em", ["impr_2pl"] = "e", ["impr_3pl"] = "u", }

stem_endings["pres_part"] = { ["pres_part"] = "v", }

stem_endings["past_part"] = { --["cond_perf_1sg"] = "uksin", --["cond_perf_2sg"] = "uksid", --["cond_perf_3sg"] = "uks", --["cond_perf_1pl"] = "uksime", --["cond_perf_2pl"] = "uksite", --["cond_perf_3pl"] = "uksid", ["past_part"] = "ud", }

stem_endings["pres_pasv"] = { ["pres_pasv"] = "akse", }

stem_endings["past_pasv_part"] = { ["pres_pasv_conn"] = "a", ["past_pasv"] = "i", ["cond_pasv"] = "aks", ["cond_pasv_conn"] = "aks", ["impr_pasv"] = "agu", ["quot_pasv"] = "avat", ["ma_inf_pasv"] = "ama", ["pres_pasv_part"] = "av", ["past_pasv_part"] = "ud", }

local function process_stems(data, stems) -- Go through each of the stems given for stem_key, substems in pairs(stems) do		for _, stem in ipairs(substems) do			-- Attach the endings to the stem for form_key, ending in pairs(stem_endings[stem_key]) do				if not data.forms[form_key] then data.forms[form_key] = {} end table.insert(data.forms[form_key], stem .. ending) end end end end

inflections["elama"] = function(args, data) data.title = "ÕS type 27/elama, no gradation" table.insert(data.categories, lang:getCanonicalName .. " elama-type verbs") local params = get_params(args, 1) if mw.ustring.find(params.base, "`") then require("Module:debug").track("mhy-verbs/`") end local stems = {} stems["ma_inf"]        = {params.base} stems["da_inf"]        = {params.base .. "d"} stems["pres"]          = {params.base} stems["past"]          = {params.base .. "si"} stems["past_3sg"]      = {params.base .. "s"} stems["impr"]          = {params.base .. "g"} stems["pres_part"]     = {params.base} stems["past_part"]     = {params.base .. "n"} stems["pres_pasv"]     = {params.base .. "t"} stems["past_pasv_part"] = {params.base .. "t"} process_stems(data, stems) end

inflections["õppima"] = function(args, data) data.title = "ÕS type 28/õppima" table.insert(data.categories, lang:getCanonicalName .. " õppima-type verbs") local params = get_params(args, 4) if params.strong == params.weak then data.title = data.title .. ", no gradation" else data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation" end local weak_stem = params.base .. params.weak .. params.final if params.weak == "" then if mw.ustring.find(params.base, "u$") and params.final == "e" then -- lugema weak_stem = mw.ustring.gsub(params.base, "u$", "o") .. "e" elseif mw.ustring.find(params.base, "i$") and params.final == "u" then -- siduma weak_stem = mw.ustring.gsub(params.base, "i$", "e") .. "o" end end local stems = {} stems["ma_inf"]        = {params.base .. params.strong .. params.final} stems["da_inf"]        = {params.base .. params.strong .. params.final .. "d"} stems["pres"]          = {weak_stem} stems["past"]          = {params.base .. params.strong .. params.final .. "si"} stems["past_3sg"]      = {params.base .. params.strong .. params.final .. "s"} stems["impr"]          = {params.base .. params.strong .. params.final .. "g"} stems["pres_part"]     = {params.base .. params.strong .. params.final} stems["past_part"]     = {params.base .. params.strong .. params.final .. "n"} stems["pres_pasv"]     = {weak_stem .. "t"} stems["past_pasv_part"] = {weak_stem .. "t"} process_stems(data, stems) end

inflections["nägema"] = function(args, data) data.title = "ÕS type 28h/nägema, g-ø gradation" table.insert(data.categories, lang:getCanonicalName .. " nägema-type verbs") local params = get_params(args, 1) local stems = {} stems["ma_inf"]        = {params.base .. "ge"} stems["da_inf"]        = {params.base .. "ha"} stems["pres"]          = {params.base .. "e"} stems["past"]          = {params.base .. "gi"} stems["past_3sg"]      = {params.base .. "gi"} stems["impr"]          = {params.base .. "hk"} stems["pres_part"]     = {params.base .. "ge"} stems["past_part"]     = {params.base .. "in"} stems["pres_pasv"]     = {params.base .. "h"} stems["past_pasv_part"] = {params.base .. "ht"} process_stems(data, stems) end

inflections["hüppama"] = function(args, data) data.title = "ÕS type 29/hüppama" table.insert(data.categories, lang:getCanonicalName .. " hüppama-type verbs") local params = get_params(args, 4) if params.strong == params.weak then data.title = data.title .. ", no gradation" else data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation" end local stems = {} stems["ma_inf"]        = {params.base .. params.strong .. params.final} stems["da_inf"]        = {params.base .. params.weak .. params.final .. "t"} stems["pres"]          = {params.base .. params.strong .. params.final} stems["past"]          = {params.base .. params.strong .. params.final .. "si"} stems["past_3sg"]      = {params.base .. params.strong .. params.final .. "s"} stems["impr"]          = {params.base .. params.weak .. params.final .. "k"} stems["pres_part"]     = {params.base .. params.strong .. params.final} stems["past_part"]     = {params.base .. params.weak .. params.final .. "n"} stems["pres_pasv"]     = {params.base .. params.weak .. params.final .. "t"} stems["past_pasv_part"] = {params.base .. params.weak .. params.final .. "t"} process_stems(data, stems) end

inflections["vaidlema"] = function(args, data) data.title = "ÕS type 30/vaidlema" table.insert(data.categories, lang:getCanonicalName .. " vaidlema-type verbs") local params = get_params(args, 3) if params.strong == params.weak then data.title = data.title .. ", no gradation" else data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation" end local weak_stem = params.base .. params.weak .. "e" -- Temporary, only handles ütlema for now if params.weak == "" then if mw.ustring.find(params.base, "ü$") then weak_stem = mw.ustring.gsub(params.base, "ü$", "ö") .. "e" end end local stems = {} stems["ma_inf"]        = {params.base .. params.strong .. "le"} stems["da_inf"]        = {weak_stem .. "ld"} stems["pres"]          = {params.base .. params.strong .. "le"} stems["past"]          = {params.base .. params.strong .. "lesi"} stems["past_3sg"]      = {params.base .. params.strong .. "les"} stems["impr"]          = {weak_stem .. "lg"} stems["pres_part"]     = {params.base .. params.strong .. "le"} stems["past_part"]     = {weak_stem .. "ln"} stems["pres_pasv"]     = {weak_stem .. "ld"} stems["past_pasv_part"] = {weak_stem .. "ld"} process_stems(data, stems) end

inflections["rabelema"] = function(args, data) data.title = "ÕS type 31/rabelema, no gradation" table.insert(data.categories, lang:getCanonicalName .. " rabelema-type verbs") local params = get_params(args, 1) local stems = {} stems["ma_inf"]        = {params.base .. "ele"} stems["da_inf"]        = {params.base .. "eld"} stems["pres"]          = {params.base .. "ele"} stems["past"]          = {params.base .. "elesi"} stems["past_3sg"]      = {params.base .. "eles"} stems["impr"]          = {params.base .. "elg"} stems["pres_part"]     = {params.base .. "ele"} stems["past_part"]     = {params.base .. "eln"} stems["pres_pasv"]     = {params.base .. "eld"} stems["past_pasv_part"] = {params.base .. "eld"} process_stems(data, stems) end

inflections["seisma"] = function(args, data) data.title = "ÕS type 32/seisma" table.insert(data.categories, lang:getCanonicalName .. " seisma-type verbs") local params = get_params(args, 4) if params.strong == params.weak then data.title = data.title .. ", no gradation" else data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation" end local stems = {} stems["ma_inf"]        = {params.base .. params.strong .. "s"} stems["da_inf"]        = {params.base .. params.strong .. "st"} stems["pres"]          = {params.base .. params.weak .. "s" .. params.final} stems["past"]          = {params.base .. params.strong .. "si"} stems["past_3sg"]      = {params.base .. params.strong .. "sis"} stems["impr"]          = {params.base .. params.strong .. "sk"} stems["pres_part"]     = {params.base .. params.strong .. "se"} stems["past_part"]     = {params.base .. params.strong .. "sn"} stems["pres_pasv"]     = {params.base .. params.strong .. "st"} stems["past_pasv_part"] = {params.base .. params.strong .. "st"} process_stems(data, stems) end

inflections["naerma"] = function(args, data) data.title = "ÕS type 33/naerma" table.insert(data.categories, lang:getCanonicalName .. " naerma-type verbs") local params = get_params(args, 4) if params.strong == params.weak then data.title = data.title .. ", no gradation" else data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation" end local stems = {} stems["ma_inf"]        = {params.base .. params.strong} stems["da_inf"]        = {params.base .. params.strong .. "d"} stems["pres"]          = {params.base .. params.weak .. params.final} stems["past"]          = {params.base .. params.strong .. "si"} stems["past_3sg"]      = {params.base .. params.strong .. "is"} stems["impr"]          = {params.base .. params.strong .. "g"} stems["pres_part"]     = {params.base .. params.strong .. "e"} stems["past_part"]     = {params.base .. params.strong .. "n"} stems["pres_pasv"]     = {params.base .. params.strong .. "d"} stems["past_pasv_part"] = {params.base .. params.strong .. "d"} process_stems(data, stems) end

inflections["saatma"] = function(args, data) data.title = "ÕS type 34/saatma" table.insert(data.categories, lang:getCanonicalName .. " saatma-type verbs") local params = get_params(args, 4) if params.strong == params.weak then data.title = data.title .. ", no gradation" else data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation" end local weak_stem = params.base .. params.weak .. params.final local pasv_stem = params.base .. params.weak .. "e" if params.weak == "" then if mw.ustring.find(params.base, "ea$") and params.final == "a" then -- teadma weak_stem = params.base pasv_stem = params.base end end local stems = {} stems["ma_inf"]        = {params.base .. params.strong} stems["da_inf"]        = {params.base .. params.strong} stems["pres"]          = {weak_stem} stems["past"]          = {params.base .. params.strong .. "si"} stems["past_3sg"]      = {params.base .. params.strong .. "is"} stems["impr"]          = {params.base .. params.strong .. "k"} stems["pres_part"]     = {params.base .. params.strong .. "e"} stems["past_part"]     = {params.base .. params.strong .. "n"} stems["pres_pasv"]     = {pasv_stem .. "t"} stems["past_pasv_part"] = {pasv_stem .. "t"} process_stems(data, stems) end

inflections["petma"] = function(args, data) data.title = "ÕS type 35/petma" table.insert(data.categories, lang:getCanonicalName .. " petma-type verbs") local params = get_params(args, 4) if params.strong == params.weak then data.title = data.title .. ", no gradation" else data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation" end local cons = mw.ustring.sub(params.base .. params.strong, -1) local stems = {} stems["ma_inf"]        = {params.base .. params.strong} stems["da_inf"]        = {params.base .. params.strong .. cons} stems["pres"]          = {params.base .. params.weak .. params.final} stems["past"]          = {params.base .. params.strong .. "si"} stems["past_3sg"]      = {params.base .. params.strong .. cons .. "is"} stems["impr"]          = {params.base .. params.strong .. "k"} stems["pres_part"]     = {params.base .. params.strong .. cons .. "e"} stems["past_part"]     = {params.base .. params.strong .. "n"} stems["pres_pasv"]     = {params.base .. params.weak .. "et"} stems["past_pasv_part"] = {params.base .. params.weak .. "et"} process_stems(data, stems) end

inflections["tulema"] = function(args, data) data.title = "ÕS type 36/tulema" table.insert(data.categories, lang:getCanonicalName .. " tulema-type verbs") local params = get_params(args, 4) if params.strong == params.weak then data.title = data.title .. ", no gradation" else data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation" end local cons_strong = mw.ustring.sub(params.base .. params.strong, -1) local cons_weak = mw.ustring.sub(params.base .. params.weak, -1) local stems = {} stems["ma_inf"]        = {params.base .. params.weak .. params.final} stems["da_inf"]        = {params.base .. params.strong .. (cons_strong == "s" and "t" or cons_strong)} stems["pres"]          = {params.base .. params.weak .. params.final} stems["past"]          = {params.base .. params.weak .. "i"} stems["past_3sg"]      = {params.base .. params.weak .. "i"} stems["impr"]          = {params.base .. params.weak .. (cons_weak == "s" and "k" or "g")} stems["pres_part"]     = {params.base .. params.weak .. "e"} stems["past_part"]     = {params.base .. params.weak .. "n"} stems["pres_pasv"]     = {params.base .. params.weak .. (cons_weak == "s" and "t" or cons_weak)} stems["past_pasv_part"] = {params.base .. params.strong .. (cons_strong == "s" and "t" or "d")} process_stems(data, stems) end

inflections["olema"] = function(args, data) data.title = "ÕS type 36/tulema, irregular, no gradation" table.insert(data.categories, lang:getCanonicalName .. " tulema-type verbs") table.insert(data.categories, lang:getCanonicalName .. " irregular verbs") local stems = {} stems["ma_inf"]        = {"ole"} stems["da_inf"]        = {"oll"} stems["pres"]          = {"ole"} stems["past"]          = {"oli"} stems["past_3sg"]      = {"oli"} stems["impr"]          = {"olg"} stems["pres_part"]     = {"ole"} stems["past_part"]     = {"oln"} stems["pres_pasv"]     = {"oll"} stems["past_pasv_part"] = {"old"} process_stems(data, stems) data.forms["pres_3sg"] = {"on"} data.forms["pres_3pl"] = {"on"} end

inflections["minema"] = function(args, data) data.title = "ÕS type 36/tulema and 34/saatma, suppletive, k-ø gradation" table.insert(data.categories, lang:getCanonicalName .. " tulema-type verbs") table.insert(data.categories, lang:getCanonicalName .. " saatma-type verbs") table.insert(data.categories, lang:getCanonicalName .. " suppletive verbs") local stems = {} stems["ma_inf"]        = {"mine"} stems["da_inf"]        = {"minn"} stems["pres"]          = {"lähe"} stems["past"]          = {"läksi"} stems["past_3sg"]      = {"läks"} stems["impr"]          = {"ming"} stems["pres_part"]     = {"mine"} stems["past_part"]     = {"läin"} stems["pres_pasv"]     = {"minn"} stems["past_pasv_part"] = {"mind"} process_stems(data, stems) data.forms["impr_2sg"] = {"mine"} end

inflections["võima"] = function(args, data) data.title = "ÕS type 37/võima, no gradation" table.insert(data.categories, lang:getCanonicalName .. " võima-type verbs") local params = get_params(args, 1) local i = args["i"]; if i == "" then i = nil end local i_stem = mw.ustring.gsub(params.base, "([aeiouäöüõ])%1$", "%1i") local stems = {} stems["ma_inf"]        = {params.base} stems["da_inf"]        = {params.base .. "d"} stems["pres"]          = {params.base} stems["past"]          = {(i and i_stem or params.base .. "si")} stems["past_3sg"]      = {(i and i_stem or params.base .. "s")} stems["impr"]          = {params.base .. "g"} stems["pres_part"]     = {params.base} stems["past_part"]     = {params.base .. "n"} stems["pres_pasv"]     = {params.base .. "d"} stems["past_pasv_part"] = {params.base .. "d"} process_stems(data, stems) end

inflections["käima"] = function(args, data) data.title = "ÕS type 38/käima, no gradation" table.insert(data.categories, lang:getCanonicalName .. " käima-type verbs") local params = get_params(args, 1) local vowels params.base, vowels = mw.ustring.match(params.base, "^(.-)([aeiouäöüõ]*)$") local raised_vowels = vowels local past_vowels = mw.ustring.gsub(vowels, "([aeiouäöüõ])%1$", "%1i") if raised_vowels == "oo" then -- jooma raised_vowels = "uu" elseif raised_vowels == "öö" then -- sööma raised_vowels = "üü" end if past_vowels == "oi" or past_vowels == "öi" then -- jooma, sööma past_vowels = "õi" end local stems = {} stems["ma_inf"]        = {params.base .. vowels} stems["da_inf"]        = {params.base .. raised_vowels} stems["pres"]          = {params.base .. vowels} stems["past"]          = {params.base .. (vowels == past_vowels and vowels .. "si" or past_vowels)} stems["past_3sg"]      = {params.base .. past_vowels .. (vowels == past_vowels and "s" or "")} stems["impr"]          = {params.base .. vowels .. "g"} stems["pres_part"]     = {params.base .. vowels} stems["past_part"]     = {params.base .. vowels .. "n"} stems["pres_pasv"]     = {params.base .. raised_vowels} stems["past_pasv_part"] = {params.base .. vowels .. "d"} process_stems(data, stems) end

function postprocess(args, data) local function addbefore(dest_key, source_key, prefix) if not data.forms[source_key] then return end data.forms[dest_key] = data.forms[dest_key] or {} for _, subform in ipairs(data.forms[source_key]) do			if not subform:find("", nil, true) then				table.insert(data.forms[dest_key], prefix .. "[[" .. subform .. "")			else				table.insert(data.forms[dest_key], prefix .. subform)			end		end	end	-- Present analytic forms	addbefore("pres_neg", "pres_conn", "ei ")	addbefore("pres_pasv_neg", "pres_pasv_conn", "ei ")	addbefore("pres_perf_1sg", "past_part", "olen ")	addbefore("pres_perf_2sg", "past_part", "oled ")	addbefore("pres_perf_3sg", "past_part", "on ")	addbefore("pres_perf_1pl", "past_part", "oleme ")	addbefore("pres_perf_2pl", "past_part", "olete ")	addbefore("pres_perf_3pl", "past_part", "on ")	addbefore("pres_perf_pasv", "past_pasv_part", "on ")	addbefore("pres_perf_neg", "past_part", "ei ole ")	addbefore("pres_perf_neg", "past_part", "pole ")	addbefore("pres_perf_pasv_neg", "past_pasv_part", "ei ole ")	addbefore("pres_perf_pasv_neg", "past_pasv_part", "pole ")	-- Past analytic forms	addbefore("past_neg", "past_part", "ei ")	addbefore("past_pasv_neg", "past_pasv_part", "ei ")	addbefore("past_perf_1sg", "past_part", "olin ")	addbefore("past_perf_2sg", "past_part", "olid ")	addbefore("past_perf_3sg", "past_part", "oli ")	addbefore("past_perf_1pl", "past_part", "olime ")	addbefore("past_perf_2pl", "past_part", "olite ")	addbefore("past_perf_3pl", "past_part", "oli ")	addbefore("past_perf_pasv", "past_pasv_part", "oli ")	addbefore("past_perf_neg", "past_part", "ei olnud ")	addbefore("past_perf_neg", "past_part", "polnud ")	addbefore("past_perf_pasv_neg", "past_pasv_part", "ei olnud ")	addbefore("past_perf_pasv_neg", "past_pasv_part", "polnud ")	-- Conditional analytic forms	addbefore("cond_neg", "cond_conn", "ei ")	addbefore("cond_pasv_neg", "cond_pasv_conn", "ei ")	addbefore("cond_perf_1sg", "past_part", "oleksin ")	addbefore("cond_perf_2sg", "past_part", "oleksid ")	addbefore("cond_perf_3sg", "past_part", "oleks ")	addbefore("cond_perf_1pl", "past_part", "oleksime ")	addbefore("cond_perf_2pl", "past_part", "oleksite ")	addbefore("cond_perf_3pl", "past_part", "oleksid ")	addbefore("cond_perf_pasv", "past_pasv_part", "oleks ")	addbefore("cond_perf_neg", "past_part", "ei oleks ")	addbefore("cond_perf_neg", "past_part", "poleks ")	addbefore("cond_perf_pasv_neg", "past_pasv_part", "ei oleks ")	addbefore("cond_perf_pasv_neg", "past_pasv_part", "poleks ")	-- Imperative analytic forms	addbefore("impr_2sg_neg", "impr_2sg", "ära ")	addbefore("impr_3sg_neg", "impr_3sg", "ärgu ")	addbefore("impr_1pl_neg", "impr_1pl", "ärgem ")	addbefore("impr_2pl_neg", "impr_2pl", "ärge ")	addbefore("impr_3pl_neg", "impr_3pl", "ärgu ")	addbefore("impr_pasv_neg", "impr_pasv", "ärgu ")	addbefore("impr_perf_3sg", "past_part", "olgu ")	addbefore("impr_perf_3pl", "past_part", "olgu ")	addbefore("impr_perf_pasv", "past_pasv_part", "olgu ")	addbefore("impr_perf_3sg_neg", "past_part", "ärgu olgu ")	addbefore("impr_perf_3pl_neg", "past_part", "ärgu olgu ")	addbefore("impr_perf_pasv_neg", "past_pasv_part", "ärgu olgu ")	-- Quotative analytic forms	addbefore("quot_neg", "quot", "ei ")	addbefore("quot_pasv_neg", "quot_pasv", "ei ")	addbefore("quot_perf", "past_part", "olevat ")	addbefore("quot_perf_pasv", "past_pasv_part", "olevat ")	addbefore("quot_perf_neg", "past_part", "ei olevat ")	addbefore("quot_perf_neg", "past_part", "polevat ")	addbefore("quot_perf_pasv_neg", "past_pasv_part", "ei olevat ")	addbefore("quot_perf_pasv_neg", "past_pasv_part", "polevat ")	-- Check if the lemma form matches the page name	if data.forms["ma_inf"] and lang:makeEntryName(data.forms["ma_inf"][1]) ~= 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 show_form(form) if not form then return "&mdash;" elseif type(form) ~= "table" then error("a non-table value was given in the list of inflected forms.") end local ret = {} for key, subform in ipairs(form) do			if subform:find("{{{") then table.insert(ret, m_links.full_link(nil, subform, lang, nil, nil, nil, {}, false)) elseif mw.ustring.find(subform, "[`']") then -- TODO: Should use the standard language-agnostic features for character replacements here table.insert(ret, m_links.full_link(mw.ustring.gsub(subform, "[`']", ""), subform, lang, nil, nil, nil, {}, false)) else table.insert(ret, m_links.full_link(subform, nil, lang, nil, nil, nil, {}, false)) end end return table.concat(ret, " ") end local function repl(param) if param == "lemma" then return m_links.full_link(nil, mw.title.getCurrentTitle.text, lang, nil, "term", nil, {}, false) elseif param == "info" then return data.title and " (" .. data.title .. ")" or "" else return show_form(data.forms[param]) end end local wikicode = [=[ Inflection of {{{lemma}}}{{{info}}} ]=]

return mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl) end

return export