Module:et-verbs

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

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

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, "et-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", ["neg_part"] = "matu", }

stem_endings["da_inf"] = { ["da_inf"] = "a", ["da_inf_ine"] = "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("et-verbs/`") end local pres_pasv_stem = "" local past_pasv_part_stem = "" local past_part_stem = "" if params.base == "kaitse" then pres_pasv_stem = "kaitst" past_pasv_part_stem = "kaitst" past_part_stem = "kaitsn" elseif params.base == "aja" then pres_pasv_stem = "aet" past_pasv_part_stem = "aet" past_part_stem = "ajan" else pres_pasv_stem = params.base .. "t" past_pasv_part_stem = params.base .. "t" past_part_stem = params.base .. "n" 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"]     = {past_part_stem} stems["pres_pasv"]     = {pres_pasv_stem} stems["past_pasv_part"] = {past_pasv_part_stem} 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 local passive_stem local past_stem weak_stem = params.base .. params.weak .. params.final --handles verbs with irregular weak stems 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" elseif mw.ustring.find(params.base, "a$") and params.final == "u" then -- kaduma weak_stem = params.base .. "o" elseif mw.ustring.find(params.base, "e$") and params.final == "a" then -- vedama passive_stem = params.base .. "e" elseif mw.ustring.find(params.base, "i$") and params.final == "a" then -- pidama weak_stem = mw.ustring.gsub(params.base, "i$", "e") .. "a" passive_stem = mw.ustring.gsub(params.base, "i$", "e") .. "e" end end if not passive_stem then passive_stem = weak_stem 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"]     = {passive_stem .. "t"} stems["past_pasv_part"] = {passive_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 .. "h"} 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) local t_stem = params.base .. params.strong local past_stem = params.base .. params.strong .. "i" local past_3sg_stem = params.base .. params.strong .. "is" if params.strong == params.weak then data.title = data.title .. ", length gradation" else data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation" end if params.base == "jooks" then t_stem = "joos" end if params.base == "kaits" then past_stem = "kaitsesi" past_3sg_stem = "kaitses" end

local stems = {} stems["ma_inf"]        = {params.base .. params.strong} stems["da_inf"]        = {t_stem .. "t"} stems["pres"]          = {params.base .. params.weak .. params.final} stems["past"]          = {past_stem} stems["past_3sg"]      = {past_3sg_stem} 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"]     = {t_stem .. "t"} stems["past_pasv_part"] = {t_stem .. "t"} 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 -- andma, kündma, etc w/ different passives if params.weak == "nn" then pasv_stem = params.base .. "n" 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["leidma"] = 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

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 pasv_stem = params.base .. params.weak if mw.ustring.find(params.base, "ü$") then pasv_stem = mw.ustring.gsub(params.base, "ü$", "ö") end 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"]     = {pasv_stem .. "et"} stems["past_pasv_part"] = {pasv_stem .. "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

inflections["laskma"] = function(args, data) data.title = "ÕS type 34/saatma, irregular gradation" table.insert(data.categories, lang:getCanonicalName .. " saatma-type verbs") local stems = {} stems["ma_inf"]        = {"lask"} stems["da_inf"]        = {"last"} stems["pres"]          = {"lase"} stems["past"]          = {"lasi", "lasksi"} stems["past_3sg"]      = {"lasi", "laskis"} stems["impr"]          = {"lask"} stems["pres_part"]     = {"laske"} stems["past_part"]     = {"laskn"} stems["pres_pasv"]     = {"last"} stems["past_pasv_part"] = {"last"} process_stems(data, stems) data.forms["impr_2sg"] = {"lase"} end

inflections["pidama"] = function(args, data) data.title = "ÕS type 34/õppima, defective, d-ø gradation" table.insert(data.categories, lang:getCanonicalName .. " õppima-type verbs") local stems = {} stems["ma_inf"]        = {"pida"} stems["da_inf"]        = {"pidad"} stems["pres"]          = {"pea"} stems["past"]          = {"pidi"} stems["past_3sg"]      = {"pidi"} stems["pres_part"]     = {"pida"} stems["past_part"]     = {"pidan"}

process_stems(data, stems) data.forms["impr_2sg"] = {"—"} end

local adp_after = { "pres_1sg", "pres_2sg", "pres_3sg", "pres_1pl", "pres_2pl", "pres_3pl", "pres_pasv", "pres_neg", "pres_pasv_neg",

"past_1sg", "past_3sg", "past_2sg", "past_1pl", "past_2pl", "past_3pl", "past_pasv", "past_neg", "past_pasv_neg",

"cond_1sg", "cond_2sg", "cond_3sg", "cond_1pl", "cond_2pl", "cond_3pl", "cond_pasv", "cond_neg", "cond_pasv_neg", "impr_2sg", "impr_2sg_neg", "impr_3sg", "impr_3sg_neg", "impr_1pl", "impr_1pl_neg", "impr_2pl", "impr_2pl_neg", "impr_3pl", "impr_3pl_neg", "impr_pasv", "impr_pasv_neg",

"quot", "quot_pasv", "quot_neg", "quot_pasv_neg", }

local adp_after_preperf = { "cond_perf_1sg", "cond_perf_2sg", "cond_perf_3sg", "cond_perf_1pl", "cond_perf_2pl", "cond_perf_3pl", "cond_perf_pasv", "cond_perf_neg", "cond_perf_pasv_neg", }

local adp_before = { "ma_inf", "ma_inf_pasv", "ma_inf_ine", "ma_inf_ela", "ma_inf_tra", "ma_inf_abe", "da_inf", "da_inf_ine", "pres_part", "pres_pasv_part", "past_part", "past_pasv_part", "neg_part", }

function postprocess(args, data) local adppref = args["adp"] and args["adp"] .. " " or ""

local function addbefore(dest_key, source_key, prefix, add_adp) if not data.forms[source_key] then return end

if add_adp then prefix = prefix .. adppref 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	local function addadpbefore(key, prefix)		local forms = data.forms[key]		if not forms then			return		end

local adp_link = prefix:find("", nil, true)		for i, subform in ipairs(forms) do			if not subform:find("[[", nil, true) then				if adp_link then					forms[i] = prefix .. "[[" .. subform .. ""				else					forms[i] = "" .. prefix .. subform .. ""				end			else				forms[i] = prefix .. subform			end		end	end	local function addadpafter(key, suffix)		local forms = data.forms[key]		if not forms then			return		end		local adp_link = suffix:find("", nil, true)		for i, subform in ipairs(forms) do			if not subform:find("[[", nil, true) then				if adp_link then					forms[i] = "[[" .. subform .. "" .. suffix				else					forms[i] = "" .. subform .. suffix .. ""				end			else				forms[i] = subform .. suffix			end		end	end	if args["adp"] then		for _, formkey in ipairs(adp_after_preperf) do			addadpafter(formkey, " " .. args["adp"])		end	end	-- Present analytic forms	addbefore("pres_neg", "pres_conn", "ei ", false)	addbefore("pres_pasv_neg", "pres_pasv_conn", "ei ", false)	addbefore("pres_perf_1sg", "past_part", "olen ", true)	addbefore("pres_perf_2sg", "past_part", "oled ", true)	addbefore("pres_perf_3sg", "past_part", "on ", true)	addbefore("pres_perf_1pl", "past_part", "oleme ", true)	addbefore("pres_perf_2pl", "past_part", "olete ", true)	addbefore("pres_perf_3pl", "past_part", "on ", true)	addbefore("pres_perf_pasv", "past_pasv_part", "on ", true)	addbefore("pres_perf_neg", "past_part", "ei ole ", true)	addbefore("pres_perf_neg", "past_part", "pole ", true)	addbefore("pres_perf_pasv_neg", "past_pasv_part", "ei ole ", true)	addbefore("pres_perf_pasv_neg", "past_pasv_part", "pole ", true)	-- Past analytic forms	addbefore("past_neg", "past_part", "ei ", false)	addbefore("past_pasv_neg", "past_pasv_part", "ei ", false)	addbefore("past_perf_1sg", "past_part", "olin ", true)	addbefore("past_perf_2sg", "past_part", "olid ", true)	addbefore("past_perf_3sg", "past_part", "oli ", true)	addbefore("past_perf_1pl", "past_part", "olime ", true)	addbefore("past_perf_2pl", "past_part", "olite ", true)	addbefore("past_perf_3pl", "past_part", "oli ", true)	addbefore("past_perf_pasv", "past_pasv_part", "oli ", true)	addbefore("past_perf_neg", "past_part", "ei olnud ", true)	addbefore("past_perf_neg", "past_part", "polnud ", true)	addbefore("past_perf_pasv_neg", "past_pasv_part", "ei olnud ", true)	addbefore("past_perf_pasv_neg", "past_pasv_part", "polnud ", true)	-- Conditional analytic forms	addbefore("cond_neg", "cond_conn", "ei ", false)	addbefore("cond_pasv_neg", "cond_pasv_conn", "ei ", false)	addbefore("cond_perf_1sg", "past_part", "oleksin ", true)	addbefore("cond_perf_2sg", "past_part", "oleksid ", true)	addbefore("cond_perf_3sg", "past_part", "oleks ", true)	addbefore("cond_perf_1pl", "past_part", "oleksime ", true)	addbefore("cond_perf_2pl", "past_part", "oleksite ", true)	addbefore("cond_perf_3pl", "past_part", "oleksid ", true)	addbefore("cond_perf_pasv", "past_pasv_part", "oleks ", true)	addbefore("cond_perf_neg", "cond_perf_3sg", "ei ", true)	addbefore("cond_perf_neg", "past_part", "poleks ", true)	addbefore("cond_perf_pasv_neg", "past_pasv_part", "ei oleks ", true)	addbefore("cond_perf_pasv_neg", "past_pasv_part", "poleks ", true)	-- Imperative analytic forms	addbefore("impr_1pl_neg", "pres_1pl", "ärme ", false)	if (data.forms["impr_2sg"] == "—") then		data.forms["impr_perf_2sg"] = {"—"}		data.forms["impr_perf_3sg"] = {"—"}		data.forms["impr_perf_1pl"] = {"—"}		data.forms["impr_perf_2pl"] = {"—"}		data.forms["impr_perf_3pl"] = {"—"}		data.forms["impr_perf_pasv"] = {"—"}		data.forms["impr_2sg_neg"] = {"—"}		data.forms["impr_3sg_neg"] = {"—"}		data.forms["impr_perf_2sg_neg"] = {"—"}		data.forms["impr_perf_3sg_neg"] = {"—"}		data.forms["impr_perf_1pl_neg"] = {"—"}		data.forms["impr_perf_2pl_neg"] = {"—"}		data.forms["impr_perf_3pl_neg"] = {"—"}		data.forms["impr_perf_pasv_neg"] = {"—"}	else		addbefore("impr_perf_2sg", "past_part", "ole ", true)		addbefore("impr_perf_3sg", "past_part", "olgu ", true)		addbefore("impr_perf_1pl", "past_part", "olgem ", true)		addbefore("impr_perf_2pl", "past_part", "olge ", true)		addbefore("impr_perf_3pl", "past_part", "olgu ", true)		addbefore("impr_perf_pasv", "past_pasv_part", "olgu ", true)		addbefore("impr_2sg_neg", "impr_2sg", "ära ", false)		addbefore("impr_3sg_neg", "impr_3sg", "ärgu ", false)		addbefore("impr_perf_2sg_neg", "past_part", "ära ole ", true)		addbefore("impr_perf_3sg_neg", "past_part", "ärgu olgu ", true)		addbefore("impr_perf_1pl_neg", "past_part", "ärme oleme ", true)		addbefore("impr_perf_1pl_neg", "past_part", "ärme ole ", true)		addbefore("impr_perf_1pl_neg", "past_part", "ärgem olgem ", true)		addbefore("impr_perf_2pl_neg", "past_part", "ärge olge ", true)		addbefore("impr_perf_3pl_neg", "past_part", "ärgu olgu ", true)		addbefore("impr_perf_pasv_neg", "past_pasv_part", "ärgu olgu ", true)		addbefore("impr_1pl_neg", "impr_2sg", "ärme ", false)	end	addbefore("impr_1pl_neg", "impr_1pl", "ärgem ", false)	addbefore("impr_2pl_neg", "impr_2pl", "ärge ", false)	addbefore("impr_3pl_neg", "impr_3pl", "ärgu ", false)	addbefore("impr_pasv_neg", "impr_pasv", "ärgu ", false)	-- Quotative analytic forms	addbefore("quot_neg", "quot", "ei ", false)	addbefore("quot_pasv_neg", "quot_pasv", "ei ", false)	addbefore("quot_perf", "past_part", "olevat ", true)	addbefore("quot_perf_pasv", "past_pasv_part", "olevat ", true)	addbefore("quot_perf_neg", "past_part", "ei olevat ", true)	addbefore("quot_perf_neg", "past_part", "polevat ", true)	addbefore("quot_perf_pasv_neg", "past_pasv_part", "ei olevat ", true)	addbefore("quot_perf_pasv_neg", "past_pasv_part", "polevat ", true)	addbefore("da_inf_past", "past_part", "olla ", true)	addbefore("da_inf_past_ine", "past_part", "olles ", true)

if args["adp"] then for _, formkey in ipairs(adp_before) do addadpbefore(formkey, args["adp"] .. " ") end for _, formkey in ipairs(adp_after) do addadpafter(formkey, " " .. args["adp"]) end if not data.notes then data.notes = {} end if not data.notenumbers then data.notenumbers = {} end table.insert(data.notes, "The adposition/particle is shown here after the verb, as it would come in main clauses. In subordinate clauses, it comes before the verb.") data.notenumbers["adpnote"] = #data.notes end -- Check if the lemma form matches the page name if data.forms["ma_inf"] and (lang:makeEntryName(m_links.remove_links(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 mw.ustring.find(subform, "[`']") then -- TODO: Should use the standard language-agnostic features for character replacements here table.insert(ret, m_links.full_link({lang = lang, term = mw.ustring.gsub(subform, "[`']", ""), alt = subform})) else table.insert(ret, m_links.full_link({lang = lang, term = subform})) end end return table.concat(ret, " ") end

local function show_notes(notes) local text = '\n|-\n! Notes\n| colspan="5" | ' for i, note in ipairs(notes) do text = text .. " " .. tostring(i) .. ") " .. note .. " "		end		return "" .. text .. "\n"	end	local function repl(param)		if param == "lemma" then			return m_links.full_link({lang = lang, alt = mw.title.getCurrentTitle.text}, "term")		elseif param == "info" then			return data.title and " (" .. data.title .. ")" or ""		elseif param == "adpnotenum" then			return data.notenumbers and data.notenumbers["adpnote"] and "" .. data.notenumbers["adpnote"] .. ")" or "" elseif param == "notes" then return data.notes and show_notes(data.notes) or "" else return show_form(data.forms[param]) end end local wikicode = [=[ Conjugation of

return mw.ustring.gsub(wikicode, "", repl) end

return export