local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local lang = require("Module:languages").getByCode("li")
local export = {}
-- Devoices the stem.
local function devoice_stem(stem)
if mw.ustring.find(stem, "gg$") then
return (mw.ustring.gsub(stem, "gg$", "kk"))
elseif mw.ustring.find(stem, "dd$") then
return (mw.ustring.gsub(stem, "dd$", "tt"))
elseif mw.ustring.find(stem, "vv$") then
return (mw.ustring.gsub(stem, "vv$", "ff"))
elseif mw.ustring.find(stem, "g$") then
return (mw.ustring.gsub(stem, "g$", "ch"))
elseif mw.ustring.find(stem, "d$") then
return (mw.ustring.gsub(stem, "d$", "t"))
elseif mw.ustring.find(stem, "v$") then
return (mw.ustring.gsub(stem, "v$", "f"))
elseif mw.ustring.find(stem, "w$") then
return (mw.ustring.gsub(stem, "w$", ""))
else
return stem
end
end
local function postprocess(args, data)
if args then
table.insert(data.categories, lang:getCanonicalName() .. " separable verbs")
data.info = data.info .. ", separable"
-- Add the separable part to all the verb forms
for key, _ in pairs(data.forms) do
if key:find("_indc$") or key:find("_cond$") or key:find("_impr$") then
-- For main-clause finite forms, add the separable part after the form, separated by a space
for i, subform in ipairs(data.forms) do
data.forms = data.forms .. " " .. args .. (args and "n" or "")
end
elseif key == "inf" then
for i, subform in ipairs(data.forms) do
data.forms = args .. (args and "n" or "") .. data.forms
end
elseif key ~= "aux" then
-- For all other forms, add the separable part before the form, with no space
for i, subform in ipairs(data.forms) do
data.forms = args .. subform
end
end
end
end
-- Check if the lemma form matches the page name
if data.forms and (lang:makeEntryName(data.forms)) ~= mw.title.getCurrentTitle().text then
table.insert(data.categories, lang:getCanonicalName() .. " entries with inflection not matching pagename")
end
if args or args then
for key, _ in pairs(data.forms) do
if key:find("^1") or key:find("^2") or (args and key:find("^3pl")) then
data.forms = nil
end
end
end
end
--- Inflection functions
--- regular
function export.regular(frame)
local params = {
= {required = true, default = "{{{1}}}"},
= {required = true, default = "{{{2}}}"},
= {required = true, default = "{{{3}}}"},
= {},
= {},
= {},
= {},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local stem = args
local stem_final = devoice_stem(args or stem)
local stem_long = devoice_stem(args or args or stem)
local pst = mw.ustring.find(stem, "$") and "e" or mw.ustring.find(stem, "ss$") and "te" or "de"
local e = mw.ustring.find(stem, "ee$") and "ë" or "e"
local s = mw.ustring.find(stem_long, "s$") and "" or mw.ustring.find(stem_long, "ch$") and "ts" or "s"
local t = mw.ustring.find(stem_long, "t$") and "" or "t"
local data = {forms = {}, info = "regular", categories = {lang:getCanonicalName() .. " weak verbs"}}
data.past = true
data.forms = {stem .. "e"}
data.forms = {args}
data.forms = {args}
data.forms = {stem_final}
data.forms = {stem_long .. s}
data.forms = {stem_long .. t}
data.forms = {stem .. e .. (args and "n" or "")}
data.forms = {(args or stem) .. t}
data.forms = {stem .. e .. (args and "n" or "")}
data.forms = {stem_final}
data.forms = {stem_long .. t}
data.forms = {stem .. pst .. (args and "n" or "")}
data.forms = {stem .. pst .. "s"}
data.forms = {stem .. pst .. (args and "n" or "")}
data.forms = {stem .. pst .. (args and "n" or "")}
data.forms = {stem .. pst .. (args and "n" or "")}
data.forms = {stem .. pst .. (args and "n" or "")}
postprocess(args, data)
return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end
--- irregular
function export.irregular(frame)
local params = {
= {required = true, default = "{{{1}}}"},
= {required = true, default = "{{{2}}}"},
= {required = true, default = "{{{3}}}"},
= {required = true, default = "{{{4}}}"},
= {required = true, default = "{{{5}}}"},
= {},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local stem = args
local stem_final = devoice_stem(stem)
local stem_long = devoice_stem(args)
local s = mw.ustring.find(stem_long, "s$") and "" or mw.ustring.find(stem_long, "ch$") and "ts" or "s"
local t = mw.ustring.find(stem_long, "t$") and "" or "t"
local stem_uml = devoice_stem(args)
local su = mw.ustring.find(stem_uml, "s$") and "" or mw.ustring.find(stem_uml, "ch$") and "ts" or "s"
local tu = mw.ustring.find(stem_uml, "t$") and "" or "t"
local data = {forms = {}, info = "irregular", categories = {}}
data.forms = {stem .. "e"}
data.forms = {args}
data.forms = {args}
data.forms = {stem .. "e" .. (args and "n" or "")}
data.forms = {stem_uml .. su}
data.forms = {stem_uml .. tu}
data.forms = {stem .. "e" .. (args and "n" or "")}
data.forms = {stem_long .. t}
data.forms = {stem .. "e" .. (args and "n" or "")}
data.forms = {stem_final}
data.forms = {stem_long .. t}
postprocess(args, data)
return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end
function export.irregular_full(frame)
local params = {
= {required = true, default = "{{{1}}}"},
= {required = true, default = "{{{2}}}"},
= {required = true, default = "{{{3}}}"},
= {required = true, default = "{{{4}}}"},
= {required = true, default = "{{{5}}}"},
= {required = true, default = "{{{6}}}"},
= {required = true, default = "{{{7}}}"},
= {type = "boolean"},
= {},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
if args then
require("Module:debug").track("li-verbs/no-t")
end
local stem = args
local stem_final = devoice_stem(stem)
local stem_long = devoice_stem(args or stem)
local s = mw.ustring.find(stem_long, "s$") and "" or mw.ustring.find(stem_long, "ch$") and "ts" or "s"
local t = mw.ustring.find(stem_long, "t$") and "" or "t"
local stem_uml = devoice_stem(args)
local su = mw.ustring.find(stem_uml, "s$") and "" or mw.ustring.find(stem_uml, "ch$") and "ts" or "s"
local tu = mw.ustring.find(stem_uml, "t$") and "" or args and "" or "t"
local stem_past = args
local stem_past_dev = devoice_stem(stem_past)
if args then
stem_past_dev = stem_past
end
local sp = mw.ustring.find(stem_past_dev, "s$") and "" or args and "" or mw.ustring.find(stem_past_dev, "ch$") and "ts" or "s"
local tp = mw.ustring.find(stem_past_dev, "t$") and "" or "t"
local ssp = mw.ustring.find(stem_past_dev, "ss$") and "te" or args and "te" or args and "" or "e"
local stem_cond = args
local stem_cond_dev = devoice_stem(stem_cond)
if args then
stem_cond_dev = stem_cond
end
local sc = mw.ustring.find(stem_cond_dev, "s$") and "" or args and "" or mw.ustring.find(stem_cond_dev, "ch$") and "ts" or "s"
local tc = mw.ustring.find(stem_cond_dev, "t$") and "" or "t"
local ssc = mw.ustring.find(stem_cond_dev, "ss$") and "te" or args and "te" or args and "" or "e"
local plust = args and "t" or ""
local plt = args and "" or mw.ustring.find(stem_past, "$") and "t" or ""
local threet = args and "t" or ""
local de = args and "de" or ""
local des = args and "des" or ""
local data = {forms = {}, info = "irregular with past tense", categories = {lang:getCanonicalName() .. " irregular verbs"}}
data.cond = true
data.forms = {stem .. "e"}
data.forms = {args}
data.forms = {args}
data.forms = {stem_final}
data.forms = {stem_uml .. su}
data.forms = {stem_uml .. tu}
data.forms = {stem .. "e" .. (args and "n" or "")}
data.forms = {stem_long .. t}
data.forms = {stem .. "e" .. (args and "n" or "")}
data.forms = {stem_final}
data.forms = {stem_long .. t}
data.forms = {stem_past_dev .. plust .. de}
data.forms = {stem_past_dev .. sp .. des}
data.forms = {stem_past_dev .. plust .. threet .. de}
data.forms = {stem_past .. plt .. ssp .. de .. (args and "n" or "")}
data.forms = {stem_past_dev .. de .. tp}
data.forms = {stem_past .. plt .. ssp .. de .. (args and "n" or "")}
data.forms = {stem_cond_dev .. plust .. de}
data.forms = {stem_cond_dev .. sc .. des}
data.forms = {stem_cond_dev .. plust .. threet .. de}
data.forms = {stem_cond .. plt .. ssc .. de ..(args and "n" or "")}
data.forms = {stem_cond_dev .. de .. tc}
data.forms = {stem_cond .. plt .. ssc .. de .. (args and "n" or "")}
postprocess(args, data)
return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end
local names = {
= "infinitive",
= "participle",
= "auxiliary",
= "present<br/>indicative",
= "past<br/>indicative",
= "conditional",
= "imperative",
= "1st singular",
= "2nd singular",
= "3rd singular",
= "1st plural",
= "2nd plural",
= "3rd plural",
}
-- Make the table
function make_table(data)
local function repl(param)
if param == "info" then
return mw.getContentLanguage():ucfirst(data.info or "")
end
local forms = data.forms
if not forms then
return "—"
end
local ret = {}
for _, form in ipairs(forms) do
table.insert(ret, m_links.full_link({lang = lang, term = form}))
end
return table.concat(ret, ", ")
end
local rows = {"1sg", "2sg", "3sg", "1pl", "2pl", "3pl"}
local columns = {"pres_indc", "impr"}
if data.cond then
columns = {"pres_indc", "past_indc", "cond", "impr"}
else
columns = {"pres_indc", "past_indc", "impr"}
end
local wikicode = {}
table.insert(wikicode, "{| class=\"inflection-table vsSwitcher\" data-toggle-category=\"inflection\" style=\"background: #F9F9F9; border: 1px solid #aaa;\"")
table.insert(wikicode, "|- style=\"background: #ccc; text-align: left;\"")
table.insert(wikicode, "! class=\"vsToggleElement\" style=\"min-width: 33em;\" colspan=\"" .. tostring(#columns + 1) .. "\" | {{{info}}} (Eupen dialect)")
table.insert(wikicode, "|- class=\"vsHide\"")
table.insert(wikicode, "! style=\"background: #e2e4c0; min-width: 9em;\" | infinitive")
table.insert(wikicode, "| colspan=\"" .. tostring(#columns) .. "\" | {{{inf}}}")
table.insert(wikicode, "|- class=\"vsHide\"")
table.insert(wikicode, "! style=\"background: #e2e4c0;\" | participle")
table.insert(wikicode, "| colspan=\"" .. tostring(#columns) .. "\" | {{{ptcp}}}")
table.insert(wikicode, "|- class=\"vsHide\"")
table.insert(wikicode, "! style=\"background: #e2e4c0;\" | auxiliary")
table.insert(wikicode, "| colspan=\"" .. tostring(#columns) .. "\" | {{{aux}}}")
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #e2e4c0;\"")
table.insert(wikicode, "!")
for _, col in ipairs(columns) do
table.insert(wikicode, "! " .. names)
end
for _, row in ipairs(rows) do
table.insert(wikicode, "|- class=\"vsHide\"")
table.insert(wikicode, "! style=\"background:#DEDEDE\" | " .. names)
for _, col in ipairs(columns) do
table.insert(wikicode, "| style=\"min-width: 12em;\" | {{{" .. row .. "_" .. col .. "}}}")
end
end
table.insert(wikicode, "|- class=\"vsHide\"")
-- table.insert(wikicode, "| colspan=\"" .. tostring(#columns + 1) .. "\" | (n) or (nn) indicates the ].")
table.insert(wikicode, "|}")
wikicode = table.concat(wikicode, "\n")
return mw.ustring.gsub(wikicode, "{{{(+)}}}", repl)
end
return export