Module:fy-verbs
Appearance
- De neikommende dokumintaasje stiet op Module:fy-verbs/dokumintaasje. [bewurkje]
Oernommen fan en:Module:fy-verbs.
Wurdt noch oanpast.
local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local lang = require("Module:languages").getByCode("fy")
local export = {}
function export.weak1(frame)
local params = {
[1] = {required = true, default = "{{{1}}}"},
[2] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local stem_pres = args[1]
local stem_pres_e = args[2] or stem_pres .. "e"
local stem_past = stem_pres_e:find("[dt]e$") and stem_pres or (stem_pres .. (stem_pres_e:find("[cfhkpqsx]e$") and "t" or "d"))
local stem_past_e = stem_pres_e:find("[dt]e$") and stem_pres_e or (stem_pres .. (stem_pres_e:find("[cfhkpqsx]e$") and "t" or "d") .. "e")
local data = {forms = {}, info = "weak class 1", categories = {lang:getCanonicalName() .. " class 1 weak verbs"}}
data.forms["1sg_pres_indc"] = {stem_pres}
data.forms["2sg_pres_indc"] = {stem_pres .. (mw.ustring.find(stem_pres, "s$") and "" or "s") .. "t"}
data.forms["3sg_pres_indc"] = {stem_pres .. (mw.ustring.find(stem_pres, "t$") and "" or "t")}
data.forms["pl_pres_indc"] = {stem_pres_e}
data.forms["1sg_past_indc"] = {stem_past_e}
data.forms["2sg_past_indc"] = {stem_past_e .. "st"}
data.forms["3sg_past_indc"] = {stem_past_e}
data.forms["pl_past_indc"] = {stem_past_e .. "n"}
data.forms["impr"] = {stem_pres}
data.forms["inf"] = {stem_pres_e}
data.forms["inf_long"] = {stem_pres_e .. "n"}
data.forms["pres_ptcp"] = {stem_pres_e .. "nd"}
data.forms["past_ptcp"] = {stem_past, stem_past == stem_pres and stem_past_e .. "n" or nil}
return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end
function export.weak2(frame)
local params = {
[1] = {required = true, default = "{{{1}}}"},
[2] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local stem_pres = args[1]
local stem_pres_e = args[2] or stem_pres .. "e"
local data = {forms = {}, info = "weak class 2", categories = {lang:getCanonicalName() .. " class 2 weak verbs"}}
data.forms["1sg_pres_indc"] = {stem_pres .. "je"}
data.forms["2sg_pres_indc"] = {stem_pres_e .. "st"}
data.forms["3sg_pres_indc"] = {stem_pres_e .. "t"}
data.forms["pl_pres_indc"] = {stem_pres .. "je"}
data.forms["1sg_past_indc"] = {stem_pres_e}
data.forms["2sg_past_indc"] = {stem_pres_e .. "st"}
data.forms["3sg_past_indc"] = {stem_pres_e}
data.forms["pl_past_indc"] = {stem_pres_e .. "n"}
data.forms["impr"] = {stem_pres .. "je"}
data.forms["inf"] = {stem_pres .. "je"}
data.forms["inf_long"] = {stem_pres .. "jen"}
data.forms["pres_ptcp"] = {stem_pres .. "jend"}
data.forms["past_ptcp"] = {stem_pres_e}
return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end
function export.strong(frame)
local params = {
[1] = {required = true, default = "{{{1}}}"},
[2] = {},
[3] = {required = true, default = "{{{3}}}"},
[4] = {},
[5] = {required = true, default = "{{{5}}}", list = "past_ptcp"},
["class"] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local stem_pres = args[1]
local stem_pres_e = args[2] or stem_pres .. "e"
local stem_past = args[3]
local stem_past_e = args[4] or stem_past .. "e"
local data = {forms = {}, info = "strong" .. (args["class"] and " class " .. args["class"] or ""), categories = {lang:getCanonicalName() .. (args["class"] and " class " .. args["class"] or "") .. " strong verbs"}}
data.forms["1sg_pres_indc"] = {stem_pres}
data.forms["2sg_pres_indc"] = {stem_pres .. (mw.ustring.find(stem_pres, "s$") and "" or "s") .. "t"}
data.forms["3sg_pres_indc"] = {stem_pres .. (mw.ustring.find(stem_pres, "t$") and "" or "t")}
data.forms["pl_pres_indc"] = {stem_pres_e}
data.forms["1sg_past_indc"] = {stem_past}
data.forms["2sg_past_indc"] = {stem_past .. (mw.ustring.find(stem_pres, "s$") and "" or "s") .. "t"}
data.forms["3sg_past_indc"] = {stem_past}
data.forms["pl_past_indc"] = {stem_past_e .. "n"}
data.forms["impr"] = {stem_pres}
data.forms["inf"] = {stem_pres_e}
data.forms["inf_long"] = {stem_pres_e .. "n"}
data.forms["pres_ptcp"] = {stem_pres_e .. "nd"}
data.forms["past_ptcp"] = args[5]
return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end
local names = {
["1sg"] = "1st singular",
["2sg"] = "2nd singular",
["3sg"] = "3rd singular",
["pl"] = "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[param]
if param == "gerund" then
forms = data.forms["inf_long"]
end
if not forms then
return "—"
end
local ret = {}
for key, form in ipairs(forms) do
table.insert(ret, m_links.full_link({lang = lang, term = form, genders = (param == "gerund" and {"n"} or nil)}))
end
return table.concat(ret, ", ")
end
local rows = {"1sg", "2sg", "3sg", "pl"}
local wikicode = {}
table.insert(wikicode, "{| class=\"inflection-table vsSwitcher\" data-toggle-category=\"inflection\" style=\"border:1px solid #CCCCFF;\" cellspacing=\"1\" cellpadding=\"3\"")
table.insert(wikicode, "|- style=\"background: #CCCCFF;\"")
table.insert(wikicode, "! colspan=\"3\" class=\"vsToggleElement\" style=\"text-align: left\" | {{{info}}}")
-- Principal parts
table.insert(wikicode, "|- class=\"vsShow\" style=\"background: #F2F2FF;\"")
table.insert(wikicode, "! style=\"background: #CCCCFF; min-width: 10em;\" | infinitive")
table.insert(wikicode, "| style=\"min-width: 12em;\" | {{{inf}}}")
table.insert(wikicode, "|- class=\"vsShow\" style=\"background: #F2F2FF;\"")
table.insert(wikicode, "! style=\"background: #CCCCFF;\" | 3rd singular past")
table.insert(wikicode, "| {{{3sg_past_indc}}}")
table.insert(wikicode, "|- class=\"vsShow\" style=\"background: #F2F2FF;\"")
table.insert(wikicode, "! style=\"background: #CCCCFF;\" | past participle")
table.insert(wikicode, "| {{{past_ptcp}}}")
-- Infinitives
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
table.insert(wikicode, "! style=\"background: #CCCCFF; min-width: 10em;\" | infinitive")
table.insert(wikicode, "| colspan=\"2\" | {{{inf}}}")
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
table.insert(wikicode, "! style=\"background: #CCCCFF;\" | long infinitive")
table.insert(wikicode, "| colspan=\"2\" | {{{inf_long}}}")
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
table.insert(wikicode, "! style=\"background: #CCCCFF;\" | gerund")
table.insert(wikicode, "| colspan=\"4\" | {{{gerund}}}")
-- Indicative
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #E6E6FF;\"")
table.insert(wikicode, "! indicative")
table.insert(wikicode, "! style=\"min-width: 12em;\" | present tense")
table.insert(wikicode, "! style=\"min-width: 12em;\" | past tense")
for _, row in ipairs(rows) do
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
table.insert(wikicode, "! style=\"background: #CCCCFF\" | " .. names[row])
table.insert(wikicode, "| {{{" .. row .. "_pres_indc}}}")
table.insert(wikicode, "| {{{" .. row .. "_past_indc}}}")
end
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #E6E6FF; height: 0.5em\"")
table.insert(wikicode, "|")
table.insert(wikicode, "| colspan=\"2\" |")
-- Imperative
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
table.insert(wikicode, "! style=\"background: #CCCCFF;\" | imperative")
table.insert(wikicode, "| {{{impr}}}")
table.insert(wikicode, "| style=\"background: #E6E6FF;\" |")
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #E6E6FF; height: 0.5em\"")
table.insert(wikicode, "|")
table.insert(wikicode, "| colspan=\"2\" |")
-- Participles
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
table.insert(wikicode, "! style=\"background: #CCCCFF;\" | participles")
table.insert(wikicode, "| {{{pres_ptcp}}}")
table.insert(wikicode, "| {{{past_ptcp}}}")
table.insert(wikicode, "|}")
wikicode = table.concat(wikicode, "\n")
return mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)
end
return export