local m_links = require("Module:links")
local lang = require("Module:languages").getByCode("dum")
local export = {}
local function append(l, key, val)
if not l then
l = {}
end
table.insert(l, val)
end
local function checked(stem)
local rest, vowel, cons = mw.ustring.match(stem, "^(.-)(+)(+)$")
if not rest then
return stem
end
if mw.ustring.len(cons) == 1 and mw.ustring.len(vowel) == 1 then
if mw.ustring.find(vowel, "") then
vowel = vowel .. "e"
elseif mw.ustring.find(vowel, "") then
vowel = vowel .. "j"
elseif mw.ustring.find(vowel, "") then
vowel = vowel .. "o"
elseif mw.ustring.find(vowel, "") then
vowel = vowel .. "u"
end
end
if cons == "w" then
if mw.ustring.find(vowel, "$") then
cons = ""
else
cons = "u"
end
end
cons = mw.ustring.gsub(cons, "(.)%1", "%1")
cons = mw.ustring.gsub(cons, "c?k$", "c")
return rest .. vowel .. cons
end
local function free(stem)
if mw.ustring.find(stem, "u?w$") then
return (mw.ustring.gsub(stem, "u?w$", "u"))
else
return checked(stem)
end
end
local function devoiced(stem)
local rest, cons = mw.ustring.match(stem, "^(.-)(+)$")
if not rest then
return stem
end
cons = mw.ustring.gsub(cons, "(.)%1", "%1")
cons = mw.ustring.gsub(cons, "ng$", "nc")
cons = mw.ustring.gsub(cons, "", { = "p", = "t", = "ch", = "f"})
return rest .. cons
end
local function shortened(stem)
local rest, vowel, cons = mw.ustring.match(stem, "^(.-)(+)(+)$")
if not rest then
return stem
end
if mw.ustring.len(cons) == 1 then
if mw.ustring.find(vowel, "^e?$") then
vowel = "a"
elseif mw.ustring.find(vowel, "^e?$") then
vowel = "e"
elseif mw.ustring.find(vowel, "^o?$") then
vowel = "o"
end
end
return rest .. vowel .. cons
end
function export.weak(frame)
local params = {
= {required = true, default = "{{{1}}}"},
-- = {required = true, default = "{{{2}}}", list = "past"},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {forms = {}, info = "weak", categories = {lang:getCanonicalName() .. " weak verbs"}}
local stem_devoiced = devoiced(checked(args))
data.forms = {args .. "en"}
data.forms = {args .. "ens"}
data.forms = {args .. "ene"}
data.forms = {args .. "e"}
data.forms = {stem_devoiced .. (mw.ustring.find(stem_devoiced, "s$") and "" or "s"), args .. "es"}
data.forms = {stem_devoiced .. (mw.ustring.find(stem_devoiced, "t$") and "" or "t"), args .. "et"}
data.forms = {args .. "en"}
data.forms = {stem_devoiced .. (mw.ustring.find(stem_devoiced, "t$") and "" or "t"), args .. "et"}
data.forms = {args .. "en"}
data.forms = {args .. "e"}
data.forms = {stem_devoiced .. (mw.ustring.find(stem_devoiced, "s$") and "" or "s"), args .. "es"}
data.forms = {args .. "e"}
data.forms = {args .. "en"}
data.forms = {stem_devoiced .. (mw.ustring.find(stem_devoiced, "t$") and "" or "t"), args .. "et"}
data.forms = {args .. "en"}
data.forms = {devoiced(free(args)), args .. "e"}
data.forms = {stem_devoiced .. (mw.ustring.find(stem_devoiced, "t$") and "" or "t"), args .. "et"}
data.forms = {args .. "ende"}
--[=[
for _, past in ipairs(args) do
append(data.forms, "past_indc_1s", past .. "e")
append(data.forms, "past_indc_2s", past .. "es")
append(data.forms, "past_indc_3s", past .. "e")
append(data.forms, "past_indc_1p", past .. "en")
append(data.forms, "past_indc_2p", past .. "et")
append(data.forms, "past_indc_3p", past .. "en")
append(data.forms, "past_subj_1s", past .. "e")
append(data.forms, "past_subj_2s", past .. "es")
append(data.forms, "past_subj_3s", past .. "e")
append(data.forms, "past_subj_1p", past .. "en")
append(data.forms, "past_subj_2p", past .. "et")
append(data.forms, "past_subj_3p", past .. "en")
append(data.forms, "past_ptcp", "ge" .. devoiced(past))
end
]=]
return make_table(data)
end
function export.strong(frame)
local params = {
= {required = true, default = "{{{1}}}"},
= {required = true, default = "{{{2}}}"},
= {required = true, default = "{{{3}}}"},
= {required = true, default = "{{{4}}}"},
= {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {forms = {}, info = "strong" .. (args and " class " .. args or ""), categories = {lang:getCanonicalName() .. (args and " class " .. args or "") .. " strong verbs"}}
local pres_devoiced = devoiced(checked(args))
local pres_free = devoiced(free(args))
local impr_shortened = devoiced(free(shortened(args)))
local past_sg_devoiced = devoiced(free(args))
local past_pl_devoiced = devoiced(checked(args))
data.forms = {args .. "en"}
data.forms = {args .. "ens"}
data.forms = {args .. "ene"}
data.forms = {args .. "e"}
data.forms = {pres_devoiced .. (mw.ustring.find(pres_devoiced, "s$") and "" or "s"), args .. "es"}
data.forms = {pres_devoiced .. (mw.ustring.find(pres_devoiced, "t$") and "" or "t"), args .. "et"}
data.forms = {args .. "en"}
data.forms = {pres_devoiced .. (mw.ustring.find(pres_devoiced, "t$") and "" or "t"), args .. "et"}
data.forms = {args .. "en"}
data.forms = {args .. "e"}
data.forms = {pres_devoiced .. (mw.ustring.find(pres_devoiced, "s$") and "" or "s"), args .. "es"}
data.forms = {args .. "e"}
data.forms = {args .. "en"}
data.forms = {pres_devoiced .. (mw.ustring.find(pres_devoiced, "t$") and "" or "t"), args .. "et"}
data.forms = {args .. "en"}
data.forms = {pres_free, args .. "e"} if impr_shortened ~= pres_free then table.insert(data.forms, 1, impr_shortened) end
data.forms = {pres_devoiced .. (mw.ustring.find(pres_devoiced, "t$") and "" or "t"), args .. "et"}
data.forms = {args .. "ende"}
data.forms = {past_sg_devoiced}
data.forms = {past_pl_devoiced .. (mw.ustring.find(past_pl_devoiced, "s$") and "" or "s"), args .. "es"}
data.forms = {past_sg_devoiced}
data.forms = {args .. "en"}
data.forms = {past_pl_devoiced .. (mw.ustring.find(past_pl_devoiced, "t$") and "" or "t"), args .. "et"}
data.forms = {args .. "en"}
data.forms = {args .. "e"}
data.forms = {args .. "es"}
data.forms = {args .. "e"}
data.forms = {args .. "en"}
data.forms = {args .. "et"}
data.forms = {args .. "en"}
data.forms = {args}
return make_table(data)
end
-- Make the table
function make_table(data)
local function repl(param)
if param == "info" then
return data.info or ""
end
local form = data.forms
if not form or #form == 0 then
return "—"
end
local ret = {}
for key, subform in ipairs(form) do
table.insert(ret, m_links.full_link({lang = lang, alt = subform}))
end
return table.concat(ret, ", ")
end
local names = {
= "singular",
= "1st singular",
= "2nd singular",
= "3rd singular",
= "plural",
= "1st plural",
= "2nd plural",
= "3rd plural",
= "present",
= "past",
= "indicative",
= "subjunctive",
= "imperative",
= "infinitive",
= "in genitive",
= "in dative",
= "participle",
= "3rd sg. past",
= "3rd pl. past",
= "past participle",
}
local person_numbers = {"1s", "2s", "3s", "1p", "2p", "3p"}
local tenses = {"pres", "past"}
local moods = {"indc", "subj", "impr", "ptcp"}
local infs = {"inf", "inf_gen", "inf_dat"}
local wikicode = mw.getCurrentFrame():expandTemplate{
title = 'inflection-table-top',
args = {
title = "Conjugation of ''{{{inf}}}'' ({{{info}}})",
palette = 'indigo',
tall = 'yes',
}
} .. [=[
|-
! rowspan="3" | infinitive
! class="secondary" | base form
| colspan="2" | {{{inf}}}
| class="blank-end-row" rowspan="3" colspan="3" |
|-
! class="secondary" | genitive
| colspan="2" | {{{inf_gen}}}
|-
! class="secondary" | dative
| colspan="2" | {{{inf_dat}}}
|-
| class="separator" colspan="4" |
| class="separator" colspan="1" rowspan="1" |
| class="separator" colspan="3" |
|-
! class="outer" colspan="2" |
! class="outer" colspan="2" | indicative
| class="separator" rowspan="8" |
! class="outer" colspan="2" | subjunctive
|-
! colspan="2" |
! ]
! ]
! ]
! ]
|-
! colspan="2" | 1st person singular
| {{{pres_indc_1s}}}
| {{{past_indc_1s}}}
| {{{pres_subj_1s}}}
| {{{past_subj_1s}}}
|-
! colspan="2" | 2nd person singular
| {{{pres_indc_2s}}}
| {{{past_indc_2s}}}
| {{{pres_subj_2s}}}
| {{{past_subj_2s}}}
|-
! colspan="2" | 3rd person singular
| {{{pres_indc_3s}}}
| {{{past_indc_3s}}}
| {{{pres_subj_3s}}}
| {{{past_subj_3s}}}
|-
! colspan="2" | 1st person plural
| {{{pres_indc_1p}}}
| {{{past_indc_1p}}}
| {{{pres_subj_1p}}}
| {{{past_subj_1p}}}
|-
! colspan="2" | 2nd person plural
| {{{pres_indc_2p}}}
| {{{past_indc_2p}}}
| {{{pres_subj_2p}}}
| {{{past_subj_2p}}}
|-
! colspan="2" | 3rd person plural
| {{{pres_indc_3p}}}
| {{{past_indc_3p}}}
| {{{pres_subj_3p}}}
| {{{past_subj_3p}}}
|-
| class="separator" colspan="3" |
| class="blank-end-row" rowspan="4" colspan="4" |
|-
! class="outer" colspan="2" |
! class="outer" | imperative
|-
! colspan="2" | singular
| {{{impr_s}}}
|-
! colspan="2" | plural
| {{{impr_p}}}
|-
| class="separator" colspan="4" |
| class="blank-end-row" rowspan="4" colspan="4" |
|-
! colspan="2" |
! ]
! ]
|-
! colspan="2" | participle
| {{{pres_ptcp}}}
| {{{past_ptcp}}}
]=] .. mw.getCurrentFrame():expandTemplate{ title = 'inflection-table-bottom' }
return (mw.ustring.gsub(wikicode, "{{{(+)}}}", repl)) .. require("Module:utilities").format_categories(data.categories, lang)
end
return export