Module:nl-verb

Definition from Wiktionary, the free dictionary
Jump to: navigation, search
The following documentation is located at Module:nl-verb/documentation. [edit]

This module contains functions for creating inflection tables for Dutch verbs.

The bot User:MewBot uses this module to automatically create entries for verb forms. This is done through the make_bot_list function. If you want to change how the module works and it may affect the parameters or the output generated by this function, please discuss this first, in case your changes prevent the bot from working correctly.


local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
 
local lang = require("Module:languages").getLanguageByCode("nl")
 
local function link_form(form)
	if type(form) == "table" then
		for j, subform in pairs(form) do
			form[j] = link_form(subform)
		end
		return table.concat(form, ", ")
	end
	if form == "" then
		return "—"
	end
    return m_links.full_link(form, nil, lang, "Latn", nil, nil, {})
end
 
local export = {}
 
-- Within this module, conjugations are the functions that do the actual
-- conjugating by creating the forms of a basic verb (not prefixed or
-- separable). They are defined further down.
local conjugations = {}
 
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.conjugate(frame)
	local conj_type = frame.args[1] or error("Conjugation type has not been specified. Please pass parameter 1 to the module invocation.")
	local args = frame:getParent().args
	PAGENAME = mw.title.getCurrentTitle().text
	NAMESPACE = mw.title.getCurrentTitle().nsText
 
	local forms, title, categories
 
	if conjugations[conj_type] then
		forms, title, categories = conjugations[conj_type](args)
	else
		error("Unknown conjugation type '" .. conj_type .. "'")
	end
 
	local pref = args["pref"] or ""
	if pref ~= "" then
		table.insert(categories, "Dutch prefixed verbs")
		title = title .. ", prefixed"
	end
 
	local sep = args["sep"] or ""
	if sep ~= "" then
		table.insert(categories, "Dutch separable verbs")
		title = title .. ", separable"
	end
 
	sep_pref(forms, sep, pref)
 
	if (args["bot"] or "") ~= "" then
		return make_bot_list(forms, sep ~= "")
	else
		return make_table(forms, title, args["aux"] or "hebben", sep ~= "") .. m_utilities.format_categories(categories, lang)
	end
end
 
 
--[=[
	*** REGULAR VERBS (mostly) ***
]=]--
 
-- Conjugate a weak verb
conjugations["weak"] = function(args)
	local forms = {}
	local categories = {"Dutch weak verbs"}
	local title = "weak"
 
	local pres_stem = args[1] or (NAMESPACE == "Template" and "(1)") or error("The first parameter is missing")
	local pres_stemE = (args[2] or ""); if pres_stemE == "" then pres_stemE = pres_stem .. "e" else pres_stemE = pres_stemE end
 
	local dt = args["dt"] or ""; if dt == "" then if pres_stemE:find("[cfhkpqstx]e$") then dt = "t" else dt = "d" end end
	local past_stem = pres_stem:gsub("([^aeiou])i$", "%1ie") .. dt .. "e"
 
	local past_ptc_stem = (args[3] or ""); if past_ptc_stem == "" then past_ptc_stem = make_long(pres_stem) .. (pres_stem:find("[dt]$") and "" or dt) end
 
	if past_ptc_stem:find("n$") then
		table.insert(categories, "Dutch weak verbs with strong past participles")
		title = title .. " with strong past participle"
	end
 
	present(forms, pres_stem, pres_stemE)
	past(forms, past_stem, past_stem, past_stem)
	forms["past_ptc"] = past_ptc_stem
 
	-- "zeggen" has an irregular past tense alongside the regular one
	if pres_stem == "zeg" then
		local forms2 = {}
		past(forms2, "zei", "zeide", "zeidt")
 
		for key, form in pairs(forms2) do
			forms[key] = {forms2[key], forms[key]}
		end
		table.insert(categories, "Dutch irregular weak verbs")
		title = title .. ", irregular"
	end
 
	return forms, title, categories
end
 
-- Conjugate a weak verb with a past tense in -cht
conjugations["weak-cht"] = function(args)
	local forms = {}
	local categories = {"Dutch weak verbs (-cht)"}
	local title = "weak with past in ''-cht''"
 
	local pres_stem = args[1] or (NAMESPACE == "Template" and "(1)") or error("The first parameter is missing")
	local pres_stemE = args[2] or ""; if pres_stemE == "" then pres_stemE = pres_stem .. "e" end
 
	local past_stem = (args[3] or (NAMESPACE == "Template" and "(3)") or error("The third parameter is missing")) .. "cht"
 
	present(forms, pres_stem, pres_stemE)
	past(forms, past_stem, past_stem .. "e", past_stem)
	forms["past_ptc"] = past_stem
 
	return forms, title, categories
end
 
-- Conjugate a strong verb
conjugations["strong"] = function(args)
	local forms = {}
	local class = args["class"] or ""; if class ~= "" then class = " class " .. class end
	local categories = {"Dutch" .. class .. " strong verbs"}
	local title = "strong" .. class
 
	local pres_stem = args[1] or (NAMESPACE == "Template" and "(1)") or error("The first parameter is missing")
	local pres_stemE = args[4] or ""; if pres_stemE == "" then pres_stemE = pres_stem .. "e" end
 
	local past_stem = args[2] or (NAMESPACE == "Template" and "(2)") or error("The second parameter is missing")
	local past_stemT = args[6] or ""; if past_stemT == "" then past_stemT = past_stem .. (past_stem:find("t$") and "" or "t") end
	local past_stemE = args[5] or ""; if past_stemE == "" then past_stemE = past_stem .. "e" end
 
	local past_ptc_stem = args[3] or (NAMESPACE == "Template" and "(3)") or error("The third parameter is missing")
 
	-- If the final consonant of the past participle is not n, then it is a weak past participle.
	if not past_ptc_stem:find("n$") then
		table.insert(categories, "Dutch strong verbs with weak past participles")
		title = title .. " with weak past participle"
	end
 
	present(forms, pres_stem, pres_stemE)
	past(forms, past_stem, past_stemE, past_stemT)
	forms["past_ptc"] = past_ptc_stem
 
	-- "houden" and "snijden" have alternative forms without the final -d
	if pres_stem == "houd" then
		forms["pres_indc_1sg"] = {"hou", "houd"}
		forms["impr_sg"] = {"hou", "houd"}
		table.insert(categories, "Dutch irregular strong verbs")
		title = title .. ", irregular"
	elseif pres_stem == "snijd" then
		forms["pres_indc_1sg"] = {"snij", "snijd"}
		forms["impr_sg"] = {"snij", "snijd"}
		table.insert(categories, "Dutch irregular strong verbs")
		title = title .. ", irregular"
	-- If the initial or final consonants of the present stem don't match, then this verb is irregular.
	elseif pres_stem:match("^([^aeiouyj]*)") ~= past_stem:match("^([^aeiouyj]*)") or pres_stem:match("([^aeiouyj]*)$") ~= past_stem:match("([^aeiouyj]*)$") then
		table.insert(categories, "Dutch irregular strong verbs")
		title = title .. ", irregular"
	end
 
	return forms, title, categories
end
 
 
--[=[
	*** IRREGULAR VERBS ***
]=]--
 
conjugations["hebben"] = function(args)
	local forms = {}
	local categories = {"Dutch irregular weak verbs"}
	local title = "weak, irregular"
 
	present(forms, "heb", "hebbe")
	past(forms, "had", "hadde", "hadt")
	forms["past_ptc"] = "had"
 
	forms["pres_indc_u"] = {"hebt", "heeft"}
	forms["pres_indc_3sg"] = "heeft"
 
	return forms, title, categories
end
 
conjugations["kunnen"] = function(args)
	local forms = {}
	local categories = {"Dutch preterite-present verbs"}
	local title = "preterite-present"
 
	forms["pres_indc_1sg"] = "kan"
	forms["pres_indc_2sg"] = {"kunt", "kan"}
	forms["pres_indc_gij"] = "kunt"
	forms["pres_indc_3sg"] = "kan"
	forms["pres_indc_pl"]  = "kunnen"
	forms["pres_subj_sg"]  = "kunne"
 
	past(forms, "kon", "konde", "kondt")
 
	forms["impr_sg"] = ""
	forms["impr_pl"] = ""
 
	forms["pres_ptc"] = "kunnend"
	forms["past_ptc"] = "kund"
 
	return forms, title, categories
end
 
conjugations["moeten"] = function(args)
	local forms = {}
	local categories = {"Dutch preterite-present verbs"}
	local title = "preterite-present"
 
	present(forms, "moet", "moete")
	past(forms, "moest", "moeste", "moest")
	forms["past_ptc"] = "moeten"
 
	return forms, title, categories
end
 
conjugations["mogen"] = function(args)
	local forms = {}
	local categories = {"Dutch preterite-present verbs"}
	local title = "preterite-present"
 
	forms["pres_indc_1sg"] = "mag"
	forms["pres_indc_2sg"] = "mag"
	forms["pres_indc_gij"] = "moogt"
	forms["pres_indc_3sg"] = "mag"
	forms["pres_indc_pl"]  = "mogen"
	forms["pres_subj_sg"]  = "moge"
 
	past(forms, "mocht", "mochte", "mocht")
 
	forms["impr_sg"] = ""
	forms["impr_pl"] = ""
 
	forms["pres_ptc"] = "mogend"
	forms["past_ptc"] = "mogen"
 
	return forms, title, categories
end
 
conjugations["weten"] = function(args)
	local forms = {}
	local categories = {"Dutch preterite-present verbs"}
	local title = "preterite-present"
 
	present(forms, "weet", "wete")
	past(forms, "wist", "wiste", "wist")
	forms["past_ptc"] = "weten"
 
	return forms, title, categories
end
 
conjugations["willen"] = function(args)
	local forms = {}
	local forms2 = {}
	local categories = {"Dutch irregular verbs"}
	local title = "irregular"
 
	present(forms, "wil", "wille")
	past(forms, "wilde", "wilde", "wilde")
 
	-- has two possible past tenses
	past(forms2, "wou", "woude", "woudt")
	for key, form in pairs(forms2) do
		forms[key] = {forms[key], forms2[key]}
	end
 
	forms["past_ptc"] = "wild"
 
	forms["pres_indc_2sg"] = {"wil", "wilt"}
	forms["pres_indc_3sg"] = "wil"
 
	return forms, title, categories
end
 
conjugations["zijn"] = function(args)
	local forms = {}
	local categories = {"Dutch irregular verbs"}
	local title = "irregular, suppletive"
 
	present(forms, "ben", "zij")
	past(forms, "was", "ware", "waart")
	forms["past_ptc"] = "weest"
 
	forms["pres_indc_gij"] = "zijt"
	forms["pres_indc_3sg"] = "is"
	forms["impr_sg"] = {"wees", "ben"}
	forms["impr_pl"] = {"weest", "zijt"}
 
	return forms, title, categories
end
 
conjugations["zullen"] = function(args)
	local forms = {}
	local categories = {"Dutch preterite-present verbs"}
	local title = "preterite-present"
 
	forms["pres_indc_1sg"] = "zal"
	forms["pres_indc_2sg"] = {"zult", "zal"}
	forms["pres_indc_3sg"] = "zal"
	forms["pres_indc_gij"] = "zult"
	forms["pres_indc_pl"]  = "zullen"
	forms["pres_subj_sg"]  = "zulle"
 
	past(forms, "zou", "zoude", "zoudt")
 
	forms["impr_sg"] = ""
	forms["impr_pl"] = ""
 
	forms["pres_ptc"] = ""
	forms["past_ptc"] = ""
 
	return forms, title, categories
end
 
--[=[
	*** HELPER FUNCTIONS ***
]=]--
 
-- Create regular present-tense forms
function present(forms, pres_stem, pres_stemE)
	local pres_stemT = make_long(pres_stem) .. (pres_stem:find("t$") and "" or "t")
 
	forms["pres_indc_1sg"] = pres_stem
	forms["pres_indc_2sg"] = pres_stemT
	forms["pres_indc_gij"] = pres_stemT
	forms["pres_indc_3sg"] = pres_stemT
	forms["pres_indc_pl"]  = make_long(pres_stemE) .. "n"
	forms["pres_subj_sg"] = pres_stemE
 
	forms["impr_sg"] = pres_stem
	forms["impr_pl"] = pres_stemT
 
	forms["pres_ptc"] = make_long(pres_stemE) .. "nd"
end
 
-- Create regular past-tense forms
function past(forms, past_stem, past_stemE, past_stemT)
	forms["past_indc_sg"]  = past_stem
	forms["past_indc_gij"] = past_stemT
	forms["past_indc_pl"]  = past_stemE .. "n"
	forms["past_subj_sg"] = past_stemE
end
 
-- Add the separable part and unstressed prefix to all the verb forms
function sep_pref(forms, sep, pref)
	-- sepSuf is empty if sep is empty
	local sepSuf = (sep ~= "" and " " .. sep or "")
	local sepHyphen = sep
 
	-- 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 sep ~= "" and mw.ustring.find("aeiou", sep:sub(-1)) and sep:sub(-1) == (pref ~= "" and pref or forms["pres_ptc"]):sub(1,1) then
		sepHyphen = sepHyphen .. "-"
	end
 
	-- For forms without a separate main clause form
	local function add1(key)
		if forms[key] == "" then
			return
		elseif type(forms[key]) == "table" then
			for n, subform in pairs(forms[key]) do
				forms[key][n] = pref .. forms[key][n] .. sepSuf
			end
		else
			forms[key] = pref .. forms[key] .. sepSuf
		end
	end
 
	-- For forms with a separate main clause form
	local function add2(key)
		if forms[key] == "" then
			return
		elseif type(forms[key]) == "table" then
			forms[key .. "_main"] = {}
			for n, subform in pairs(forms[key]) do
				forms[key .. "_main"][n] = pref .. forms[key][n] .. sepSuf
				forms[key][n]			= sepHyphen .. pref .. forms[key][n]
			end
		else
			forms[key .. "_main"] = pref .. forms[key] .. sepSuf
			forms[key]			= sepHyphen .. pref .. forms[key]
		end
	end
 
	add2("pres_indc_1sg")
	add2("pres_indc_2sg")
	add2("pres_indc_gij")
	if forms["pres_indc_u"] then add2("pres_indc_u") end
	add2("pres_indc_3sg")
	add2("pres_indc_pl")
	add2("pres_subj_sg")
 
	add2("past_indc_sg")
	add2("past_indc_gij")
	add2("past_indc_pl")
	add2("past_subj_sg")
 
	add1("impr_sg")
	add1("impr_pl")
 
	if forms["pres_ptc"] ~= "" then forms["pres_ptc"] = sepHyphen .. pref .. forms["pres_ptc"] end
 
	if forms["past_ptc"] ~= "" then
		if pref == "" then
			if mw.ustring.find(forms["past_ptc"], "^[eiu]") and not mw.ustring.find(forms["past_ptc"], "^ij") then
				forms["past_ptc"] = forms["past_ptc"]:gsub("^e", "ë"):gsub("^i", "ï"):gsub("^u", "ü")
			end
 
			forms["past_ptc"] = sep .. "ge" .. forms["past_ptc"]
		else
			forms["past_ptc"] = sepHyphen .. pref .. forms["past_ptc"]
		end
	end
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(forms, title, aux, hasSep)
	-- Make links out of all forms
 
	for key, form in pairs(forms) do
		forms[key] = link_form(form)
	end
 
	if forms["past_ptc"] ~= "—" then
		forms["past_ptc"] = "(" .. link_form(aux) .. ") " .. forms["past_ptc"]
	end
 
	return [=[
<div class="NavFrame" style="width: ]=] .. (hasSep and 72 or 42) .. [=[em;">
<div class="NavHead" style="background: #CCCCFF; text-align: left;">Conjugation of '']=] .. forms["pres_indc_pl"] .. "''" .. (title and " (" .. title .. ")" or "") .. [=[</div>
<div class="NavContent">
{| style="width:100%; border:1px solid #CCCCFF; text-align:center; line-height:125%" class="inflection-table" cellspacing="1" cellpadding="3"
|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[infinitive]]
| colspan="4" | ]=] .. forms["pres_indc_pl"] .. [=[
 
]=] .. (hasSep and [=[|- style="background: #E6E6FF;"
|
| colspan="2" style="font-weight: bold;" | [[main&nbsp;clause]]
| colspan="2" style="font-weight: bold;" | [[subordinate&nbsp;clause]]
|- style="background: #E6E6FF;"
| 
| style="width: 25%; font-weight: bold" | [[present&nbsp;tense]]
| style="width: 25%; font-weight: bold" | [[past&nbsp;tense]]
| style="width: 25%; font-weight: bold" | [[present&nbsp;tense]]
| style="width: 25%; font-weight: bold" | [[past&nbsp;tense]]]=] or [=[
 
|- style="background: #E6E6FF;"
| 
| style="width: 50%; font-weight: bold" | [[present&nbsp;tense]]
| style="width: 50%; font-weight: bold" | [[past&nbsp;tense]]]=]) .. [=[
 
|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[first-person|1st&nbsp;person]]&nbsp;[[singular]]
| ]=] .. (hasSep and forms["pres_indc_1sg_main"] .. " || " .. forms["past_indc_sg_main"] .. " || " or "") .. forms["pres_indc_1sg"] .. " || " .. forms["past_indc_sg"] .. [=[
 
|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[second-person|2nd&nbsp;person]]&nbsp;[[singular]]
| ]=] .. (hasSep and forms["pres_indc_2sg_main"] .. " || " .. forms["past_indc_sg_main"] .. " || " or "") .. forms["pres_indc_2sg"] .. " || " .. forms["past_indc_sg"] .. [=[
 
]=] .. (forms["pres_indc_u"] and [=[|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[second-person|2nd&nbsp;person]]&nbsp;[[singular|sing.]]&nbsp;(<span lang="nl">[[u#Dutch|u]]</span>)
| ]=] .. (hasSep and forms["pres_indc_u_main"] .. " || " .. forms["past_indc_sg_main"] .. " || " or "") .. forms["pres_indc_u"] .. " || " .. forms["past_indc_sg"] .. [=[
 
]=] or "") .. ((forms["pres_indc_gij"] ~= forms["pres_indc_2sg"] or forms["past_indc_gij"] ~= forms["past_indc_sg"]) and [=[|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[second-person|2nd&nbsp;person]]&nbsp;[[singular|sing.]]&nbsp;(<span lang="nl">[[gij#Dutch|gij]]</span>)
| ]=] .. (hasSep and forms["pres_indc_gij_main"] .. " || " .. forms["past_indc_gij_main"] .. " || " or "") .. forms["pres_indc_gij"] .. " || " .. forms["past_indc_gij"] .. [=[
 
]=] or "") .. [=[|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[third-person|3rd&nbsp;person]]&nbsp;[[singular]]
| ]=] .. (hasSep and forms["pres_indc_3sg_main"] .. " || " .. forms["past_indc_sg_main"] .. " || " or "") .. forms["pres_indc_3sg"] .. " || " .. forms["past_indc_sg"] .. [=[
 
|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[plural]]
| ]=] .. (hasSep and forms["pres_indc_pl_main"] .. " || " .. forms["past_indc_pl_main"] .. " || " or "") .. forms["pres_indc_pl"] .. " || " .. forms["past_indc_pl"] .. [=[
 
|- style="background: #E6E6FF; height: 0.5em"
|
| colspan="2" |]=] .. (hasSep and [=[ || colspan="2" |]=] or "") .. [=[
 
|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[subjunctive]]&nbsp;[[singular|sing.]]<sup>1</sup>
| ]=] .. (hasSep and forms["pres_subj_sg_main"] .. " || " .. forms["past_subj_sg_main"] .. " || " or "") .. forms["pres_subj_sg"] .. " || " .. forms["past_subj_sg"] .. [=[
 
|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[subjunctive]]&nbsp;[[plural|plur.]]<sup>1</sup>
| ]=] .. (hasSep and forms["pres_indc_pl_main"] .. " || " .. forms["past_indc_pl_main"] .. " || " or "") .. forms["pres_indc_pl"] .. " || " .. forms["past_indc_pl"] .. [=[
 
|- style="background: #E6E6FF; height: 0.5em"
|
| colspan="2" |]=] .. (hasSep and [=[ || rowspan="5" colspan="2" |]=] or "") .. [=[
 
|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[imperative]]&nbsp;[[singular|sing.]]
| ]=] .. forms["impr_sg"] .. [=[
 
| rowspan="2" style="background: #E6E6FF;" |
|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[imperative]]&nbsp;[[plural|plur.]]<sup>1</sup>
| ]=] .. forms["impr_pl"] .. [=[
 
|- style="background: #E6E6FF; height: 0.5em"
|
| colspan="2" |
|- style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[participles]]
| ]=] .. forms["pres_ptc"] .. " || " .. forms["past_ptc"] .. [=[
 
|- 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]].
|}</div></div>]=]
end
 
function make_bot_list(forms, hasSep)
	local ret = ""
 
	if hasSep then
		ret = ret .. "* sep=1\n"
	end
 
	for key, form in pairs(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