Modul:nl-verbs
A modult a Modul:nl-verbs/doc lapon tudod dokumentálni
local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local lang = require("Module:languages").getByCode("nl")
local export = {}
-- Functions that do the actual inflecting by creating the forms of a basic term.
local inflections = {}
local irregular = {}
-- 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.")
if not inflections[infl_type] then
error("Unknown inflection type '" .. infl_type .. "'")
end
local params = {
["aux"] = {},
["aux2"] = {},
["bot"] = {type = "boolean"},
["pref"] = {},
["sep"] = {},
["trans"] = {},
["trans2"] = {},
["vnoun"] = {},
["vnoung"] = {},
["vnoun2"] = {},
}
for key, val in pairs(inflections[infl_type].params) do
params[key] = val
end
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {forms = {}, title = nil, categories = {}}
inflections[infl_type].func(args, data)
postprocess(args, data)
if (args["bot"] or "") ~= "" then
return make_bot_list(data, args["sep"])
else
return make_table(data, args["sep"]) .. m_utilities.format_categories(data.categories, lang)
end
end
function postprocess(args, data)
-- Verbal noun
local vnoun = args["vnoun"]
local vnoun2 = args["vnoun2"]
if vnoun then
data.forms["vnoun"] = {vnoun, vnoun2}
end
-- Prefixed and separable
local pref = args["pref"]
local sep = args["sep"]
if pref then
table.insert(data.categories, "Dutch prefixed verbs")
table.insert(data.categories, "Dutch prefixed verbs with " .. pref .. "-")
data.title = data.title .. ", prefixed"
end
if sep then
table.insert(data.categories, "Dutch separable verbs")
table.insert(data.categories, "Dutch separable verbs with " .. sep)
data.title = data.title .. ", separable"
end
if not pref and not sep then
table.insert(data.categories, "Dutch basic verbs")
end
add_pref(data, pref)
add_sep(data, sep)
data.aux = args["aux"] or "hebben"
if args["aux"] then
if args["aux"] == "zijn" then
require("Module:debug").track("nl-verb/zijn")
else
require("Module:debug").track("nl-verb/aux")
end
end
if args["aux2"] then
require("Module:debug").track("nl-verb/aux2")
end
data.trans = args["trans"]
if data.trans then
if data.trans == "acc" then
table.insert(data.categories, "Dutch accusative verbs")
elseif data.trans == "erg" then
table.insert(data.categories, "Dutch ergative verbs")
elseif data.trans == "unerg" then
table.insert(data.categories, "Dutch unergative verbs")
elseif data.trans == "unacc" then
table.insert(data.categories, "Dutch unaccusative verbs")
else
error("The \"trans=\" parameter has an invalid value. Valid are: acc, erg, unerg, unacc.")
end
end
data.trans2 = args["trans2"]
if data.trans2 then
if data.trans2 == "acc" then
table.insert(data.categories, "Dutch accusative verbs")
elseif data.trans2 == "erg" then
table.insert(data.categories, "Dutch ergative verbs")
elseif data.trans2 == "unerg" then
table.insert(data.categories, "Dutch unergative verbs")
elseif data.trans2 == "unacc" then
table.insert(data.categories, "Dutch unaccusative verbs")
else
error("The \"trans2=\" parameter has an invalid value. Valid are: acc, erg, unerg, unacc.")
end
end
if not args["trans"] then
require("Module:debug").track("nl-verb/no trans")
end
end
-- Add the unstressed prefix to all the verb forms, or
-- if there is no prefix, add ge- to the past participle
function add_pref(data, pref)
if pref then
-- Add prefix before every form
for key, form in pairs(data.forms) do
for i, subform in ipairs(form) do
data.forms[key][i] = pref .. subform
end
end
else
-- Add ge- prefix before past participle
if data.forms["past_ptc"] then
for i, subform in ipairs(data.forms["past_ptc"]) do
-- Place a diaeresis on the initial vowel of the stem if necessary
if mw.ustring.find(subform, "^[eiu]") and not mw.ustring.find(subform, "^ij") then
subform = subform:gsub("^e", "ë"):gsub("^i", "ï"):gsub("^u", "ü")
end
data.forms["past_ptc"][i] = "ge" .. subform
end
end
end
end
-- Add the separable part to all the verb forms
function add_sep(data, sep)
if not sep then
return
end
-- Add main clause forms
local mainforms = {}
for key, form in pairs(data.forms) do
if (key:find("^pres_") or key:find("^past_")) and not key:find("_ptc$") then
mainforms[key .. "_main"] = mw.clone(form)
end
end
for key, form in pairs(mainforms) do
data.forms[key] = form
end
-- Add separable part to forms
for key, form in pairs(data.forms) do
if key:find("_main$") 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[key]) do
data.forms[key][i] = data.forms[key][i] .. " " .. sep
end
else
-- For all other forms, add the separable part before the form, with no space
for i, subform in ipairs(data.forms[key]) do
-- Add a hyphen after the separable part if it ends with the same vowel
-- that the main/prefixed verb begins with, for verbs like na-apen
if mw.ustring.find("aeiou", sep:sub(-1)) and sep:sub(-1) == subform:sub(1, 1) then
subform = sep .. "-" .. subform
else
subform = sep .. subform
end
data.forms[key][i] = subform
end
end
end
end
--[=[
*** REGULAR VERBS (mostly) ***
]=]--
local function addform(data, key, form, index)
if data.forms[key] then
if index then
table.insert(data.forms[key], index, form)
else
table.insert(data.forms[key], form)
end
else
data.forms[key] = {form}
end
end
-- Conjugate a weak verb
inflections["weak"] = {
params = {
[1] = {required = true},
[2] = {},
[3] = {},
["dt"] = {},
},
func = function(args, data)
table.insert(data.categories, "Dutch weak verbs")
data.title = "weak"
local stems = {}
stems["pres"] = args[1] or "{{{1}}}"
stems["pres_e"] = args[2]
present(data, stems)
local dt = args["dt"] or (stems["pres_e"]:find("[cfhkpqstx]e$") and "t" or "d")
stems["past"] = stems["pres"]:gsub("([^aeiou])i$", "%1ie") .. dt .. "e"
past(data, stems)
stems["past_ptc"] = args[3] or make_long(stems["pres"]) .. (stems["pres"]:find("[dt]$") and "" or dt)
data.forms["past_ptc"] = {stems["past_ptc"]}
if stems["past_ptc"]:find("n$") then
table.insert(data.categories, "Dutch weak verbs with strong past participles")
data.title = data.title .. " with strong past participle"
end
-- "zeggen" has an irregular past tense alongside the regular one
if stems["pres"] == "zeg" then
past(data, {["past"] = "zei", ["past_e"] = "zeide", ["past_t"] = "zeidt"}, 1)
table.insert(data.categories, "Dutch irregular weak verbs")
data.title = data.title .. ", irregular"
end
end
}
-- Conjugate a weak verb with a past tense in -cht
inflections["weak-cht"] = {
params = {
[1] = {required = true},
[2] = {},
[3] = {required = true},
},
func = function(args, data)
table.insert(data.categories, "Dutch weak verbs (-cht)")
data.title = "weak with past in ''-cht''"
local stems = {}
stems["pres"] = args[1] or "{{{1}}}"
stems["pres_e"] = args[2]
present(data, stems)
stems["past"] = (args[3] or "{{{3}}}") .. "cht"
past(data, stems)
stems["past_ptc"] = stems["past"]
data.forms["past_ptc"] = {stems["past_ptc"]}
end
}
-- Conjugate a strong verb
inflections["strong"] = {
params = {
[1] = {required = true},
[2] = {required = true},
[3] = {required = true},
[4] = {},
[5] = {},
[6] = {},
["class"] = {},
},
func = function(args, data)
local class = args["class"]
table.insert(data.categories, "Dutch" .. (class and " class " .. class or "") .. " strong verbs")
data.title = "strong" .. (class and " class " .. class or "")
local stems = {}
stems["pres"] = args[1] or "{{{1}}}"
stems["pres_e"] = args[4]
present(data, stems)
stems["past"] = args[2] or "{{{2}}}"
stems["past_e"] = args[5]
stems["past_t"] = args[6]
past(data, stems)
stems["past_ptc"] = args[3] or "{{{3}}}"
data.forms["past_ptc"] = {stems["past_ptc"]}
-- If the final consonant of the past participle is not n, then it is a weak past participle.
if not stems["past_ptc"]:find("n$") then
table.insert(data.categories, "Dutch strong verbs with weak past participles")
data.title = data.title .. " with weak past participle"
end
-- "houden" and "snijden" have alternative forms without the final -d
if stems["pres"] == "houd" then
addform(data, "pres_indc_1sg", "hou", 1)
addform(data, "impr_sg", "hou", 1)
table.insert(data.categories, "Dutch irregular strong verbs")
data.title = data.title .. ", slightly irregular"
elseif stems["pres"] == "snijd" then
addform(data, "pres_indc_1sg", "snij", 1)
addform(data, "impr_sg", "snij", 1)
table.insert(data.categories, "Dutch irregular strong verbs")
data.title = data.title .. ", slightly irregular"
-- If the initial or final consonants of the present stem don't match, then this verb is irregular.
elseif stems["pres"]:match("^([^aeiouyj]*)") ~= stems["past"]:match("^([^aeiouyj]*)") or stems["pres"]:match("([^aeiouyj]*)$") ~= stems["past"]:match("([^aeiouyj]*)$") then
table.insert(data.categories, "Dutch irregular strong verbs")
data.title = data.title .. ", irregular"
end
end
}
-- Conjugate an irregular verb
inflections["irregular"] = {
params = {
[1] = {required = true},
},
func = function(args, data)
local base = args[1] or "zijn"
if irregular[base] then
irregular[base](data)
else
error("Unknown irregular verb '" .. base .. "'.")
end
end
}
--[=[
*** IRREGULAR VERB TYPES ***
]=]--
irregular["doen"] = function(data)
table.insert(data.categories, "Dutch irregular verbs")
data.title = "irregular"
present(data, {["pres"] = "doe", ["pres_e"] = "doe"})
past(data, {["past"] = "deed", ["past_e"] = "dede"})
data.forms["past_ptc"] = {"daan"}
data.forms["pres_indc_u"] = {"doet"}
data.forms["pres_indc_3sg"] = {"doet"}
end
irregular["hebben"] = function(data)
table.insert(data.categories, "Dutch irregular weak verbs")
data.title = "weak, irregular"
present(data, {["pres"] = "heb", ["pres_e"] = "hebbe"})
past(data, {["past"] = "had", ["past_e"] = "hadde"})
data.forms["past_ptc"] = {"had"}
data.forms["pres_indc_u"] = {"hebt", "heeft"}
data.forms["pres_indc_3sg"] = {"heeft"}
end
irregular["kunnen"] = function(data)
table.insert(data.categories, "Dutch preterite-present verbs")
data.title = "preterite-present"
present(data, {["pres"] = "kan", ["pres_e"] = "kunne", ["pres_t"] = "kunt"})
past(data, {["past"] = "kon", ["past_e"] = "konde", ["past_t"] = "kondt"})
addform(data, "pres_indc_jij", "kan")
addform(data, "pres_indc_u", "kan")
data.forms["pres_indc_3sg"] = {"kan"}
data.forms["past_ptc"] = {"kund"}
end
irregular["moeten"] = function(data)
table.insert(data.categories, "Dutch preterite-present verbs")
data.title = "preterite-present"
present(data, {["pres"] = "moet"})
past(data, {["past"] = "moest"})
data.forms["past_ptc"] = {"moeten"}
end
irregular["mogen"] = function(data)
table.insert(data.categories, "Dutch preterite-present verbs")
data.title = "preterite-present"
present(data, {["pres"] = "mag", ["pres_e"] = "moge", ["pres_t"] = "moogt"})
past(data, {["past"] = "mocht"})
data.forms["pres_indc_jij"] = {"mag"}
data.forms["pres_indc_u"] = {"mag"}
data.forms["pres_indc_3sg"] = {"mag"}
data.forms["past_ptc"] = {"mogen"}
end
irregular["weten"] = function(data)
table.insert(data.categories, "Dutch preterite-present verbs")
data.title = "preterite-present"
present(data, {["pres"] = "weet", ["pres_e"] = "wete"})
past(data, {["past"] = "wist"})
data.forms["past_ptc"] = {"weten"}
end
irregular["willen"] = function(data)
table.insert(data.categories, "Dutch irregular verbs")
data.title = "irregular"
present(data, {["pres"] = "wil", ["pres_e"] = "wille"})
past(data, {["past"] = "wilde"})
past(data, {["past"] = "wou", ["past_e"] = "woude", ["past_t"] = "woudt"})
data.forms["past_ptc"] = {"wild"}
addform(data, "pres_indc_jij", "wil")
addform(data, "pres_indc_u", "wil")
data.forms["pres_indc_3sg"] = {"wil"}
end
irregular["zijn"] = function(data)
table.insert(data.categories, "Dutch irregular verbs")
table.insert(data.categories, "Dutch suppletive verbs")
data.title = "irregular, suppletive"
present(data, {["pres"] = "ben", ["pres_e"] = "zij", ["pres_t"] = "zijt"})
past(data, {["past"] = "was", ["past_e"] = "ware", ["past_t"] = "waart"})
data.forms["past_ptc"] = {"weest"}
data.forms["pres_indc_jij"] = {"bent"}
data.forms["pres_indc_u"] = {"bent", "is"}
data.forms["pres_indc_3sg"] = {"is"}
addform(data, "impr_sg", "wees", 1)
addform(data, "impr_pl", "weest", 1)
end
irregular["zullen"] = function(data)
table.insert(data.categories, "Dutch preterite-present verbs")
data.title = "preterite-present"
present(data, {["pres"] = "zal", ["pres_e"] = "zulle", ["pres_t"] = "zult"})
past(data, {["past"] = "zou", ["past_e"] = "zoude", ["past_t"] = "zoudt"})
data.forms["pres_indc_jij"] = {"zult", "zal"}
data.forms["pres_indc_u"] = {"zult", "zal"}
data.forms["pres_indc_3sg"] = {"zal"}
end
--[=[
*** HELPER FUNCTIONS ***
]=]--
-- Create regular present-tense forms
function present(data, stems, index)
if not stems["pres_e"] then
stems["pres_e"] = stems["pres"] .. "e"
end
if not stems["pres_t"] then
if mw.ustring.find(stems["pres"], "t$") then
stems["pres_t"] = make_long(stems["pres"])
else
stems["pres_t"] = make_long(stems["pres"]) .. "t"
end
end
addform(data, "pres_indc_1sg", stems["pres"], index)
addform(data, "pres_indc_jij", stems["pres_t"], index)
addform(data, "pres_indc_gij", stems["pres_t"], index)
addform(data, "pres_indc_u" , stems["pres_t"], index)
addform(data, "pres_indc_3sg", stems["pres_t"], index)
addform(data, "pres_indc_pl" , make_long(stems["pres_e"]) .. "n", index)
addform(data, "pres_subj_sg" , stems["pres_e"], index)
addform(data, "impr_sg", stems["pres"], index)
addform(data, "impr_pl", stems["pres_t"], index)
addform(data, "infinitive", make_long(stems["pres_e"]) .. "n", index)
addform(data, "pres_ptc", make_long(stems["pres_e"]) .. "nd", index)
end
-- Create regular past-tense forms
function past(data, stems, index)
if not stems["past_e"] then
if mw.ustring.find(stems["past"], "e$") then
stems["past_e"] = stems["past"]
else
stems["past_e"] = stems["past"] .. "e"
end
end
if not stems["past_t"] then
if mw.ustring.find(stems["past"], "[^eio]e$") or mw.ustring.find(stems["past"], "[të]$") then
stems["past_t"] = stems["past"]
else
stems["past_t"] = stems["past"] .. "t"
end
end
addform(data, "past_indc_sg" , stems["past"], index)
addform(data, "past_indc_gij" , stems["past_t"], index)
addform(data, "past_indc_pl" , stems["past_e"] .. "n", index)
addform(data, "past_subj_sg" , stems["past_e"], index)
end
-- A small helper function for those few verbs that have a stem ending in a
-- vowel (like gaan, staan, skiën, echoën). This lengthens the stem-final vowel.
function make_long(form)
return (form:gsub("([^aeiou])([ao])$", "%1%2%2"):gsub("([^aeiou])i$", "%1ie"))
end
-- Make the table
function make_table(data, hasSep)
local function show_form(form)
if not form then
return "—"
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
table.insert(ret, m_links.full_link({lang = lang, term = subform}))
end
return table.concat(ret, ", ")
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 ""
else
return show_form(data.forms[param])
end
end
local wikicode = [=[
{| style="border:1px solid #CCCCFF; text-align:center; line-height:125%" class="inflection-table vsSwitcher" data-toggle-category="inflection" cellspacing="1" cellpadding="3"
|- style="background: #CCCCFF;"
! colspan="5" class="vsToggleElement" style="text-align: left" | Inflection of {{{lemma}}}{{{info}}}
|- class="vsShow" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[infinitive]]
| style="min-width: 12em;" | {{{infinitive}}}
|- class="vsShow" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[past tense|past]] [[singular]]
| ]=] .. (hasSep and "{{{past_indc_sg_main}}}" or "{{{past_indc_sg}}}") .. [=[
|- class="vsShow" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[past tense|past]] [[participle]]
| {{{past_ptc}}}
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[infinitive]]
| colspan="4" | {{{infinitive}}}
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[gerund]]
| colspan="4" | {{{infinitive}}} ]=] .. require("Module:gender and number").format_list({"n"}) .. (hasSep and [=[
|- class="vsHide" style="background: #E6E6FF;"
|
| colspan="2" style="font-weight: bold;" | [[main clause]]
| colspan="2" style="font-weight: bold;" | [[subordinate clause]]
|- class="vsHide" style="background: #E6E6FF;"
|
| style="min-width: 12em; font-weight: bold" | [[present tense]]
| style="min-width: 12em; font-weight: bold" | [[past tense]]
| style="min-width: 12em; font-weight: bold" | [[present tense]]
| style="min-width: 12em; font-weight: bold" | [[past tense]]]=] or [=[
|- class="vsHide" style="background: #E6E6FF;"
|
| style="min-width: 12em; font-weight: bold" | [[present tense]]
| style="min-width: 12em; font-weight: bold" | [[past tense]]
|-]=]) .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[first-person|1st person]] [[singular]]
| ]=] .. (hasSep and "{{{pres_indc_1sg_main}}} || {{{past_indc_sg_main}}} || " or "") .. [=[{{{pres_indc_1sg}}} || {{{past_indc_sg}}}
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[second-person|2nd person]] [[singular|sing.]] (<span lang="nl">[[jij#Dutch|jij]]</span>)
| ]=] .. (hasSep and "{{{pres_indc_jij_main}}} || {{{past_indc_sg_main}}} || " or "") .. [=[{{{pres_indc_jij}}} || {{{past_indc_sg}}}
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[second-person|2nd person]] [[singular|sing.]] (<span lang="nl">[[u#Dutch|u]]</span>)
| ]=] .. (hasSep and "{{{pres_indc_u_main}}} || {{{past_indc_sg_main}}} || " or "") .. [=[{{{pres_indc_u}}} || {{{past_indc_sg}}}
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[second-person|2nd person]] [[singular|sing.]] (<span lang="nl">[[gij#Dutch|gij]]</span>)
| ]=] .. (hasSep and "{{{pres_indc_gij_main}}} || {{{past_indc_gij_main}}} || " or "") .. [=[{{{pres_indc_gij}}} || {{{past_indc_gij}}}
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[third-person|3rd person]] [[singular]]
| ]=] .. (hasSep and "{{{pres_indc_3sg_main}}} || {{{past_indc_sg_main}}} || " or "") .. [=[{{{pres_indc_3sg}}} || {{{past_indc_sg}}}
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[plural]]
| ]=] .. (hasSep and "{{{pres_indc_pl_main}}} || {{{past_indc_pl_main}}} || " or "") .. [=[{{{pres_indc_pl}}} || {{{past_indc_pl}}}
|- class="vsHide" style="background: #E6E6FF; height: 0.5em"
|
| colspan="2" |]=] .. (hasSep and [=[ || colspan="2" |]=] or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[subjunctive]] [[singular|sing.]]<sup>1</sup>
| ]=] .. (hasSep and "{{{pres_subj_sg_main}}} || {{{past_subj_sg_main}}} || " or "") .. [=[{{{pres_subj_sg}}} || {{{past_subj_sg}}}
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[subjunctive]] [[plural|plur.]]<sup>1</sup>
| ]=] .. (hasSep and "{{{pres_indc_pl_main}}} || {{{past_indc_pl_main}}} || " or "") .. [=[{{{pres_indc_pl}}} || {{{past_indc_pl}}}
|- class="vsHide" style="background: #E6E6FF; height: 0.5em"
|
| colspan="2" |]=] .. (hasSep and [=[ || rowspan="5" colspan="2" |]=] or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[imperative]] [[singular|sing.]]
| {{{impr_sg}}}
| rowspan="2" style="background: #E6E6FF;" |
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[imperative]] [[plural|plur.]]<sup>1</sup>
| {{{impr_pl}}}
|- class="vsHide" style="background: #E6E6FF; height: 0.5em"
|
| colspan="2" |
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[participles]]
| {{{pres_ptc}}} || {{{past_ptc}}}
|- class="vsHide" style="background: #E6E6FF;"
| colspan="5" style="text-align:left; vertical-align:top; font-size: smaller; line-height: 1em" | <sup>1)</sup> [[Wiktionary:Glossary#archaic|Archaic]].
|}]=]
return mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)
end
function make_bot_list(data, hasSep)
local ret = ""
if hasSep then
ret = ret .. "* sep=1\n"
end
for key, form in pairs(data.forms) do
if type(form) == "table" then
for key2, subform in ipairs(form) do
ret = ret .. "* " .. key .. "_" .. key2 .. "=" .. subform .. "\n"
end
else
ret = ret .. "* " .. key .. "=" .. form .. "\n"
end
end
return ret
end
return export