Module:nl-verb Feb 27th 2013, 18:36 | | Line 21: | Line 21: | | elseif conj_type == "strong" then | | elseif conj_type == "strong" then | | forms, title, categories = conjugate_strong(args) | | forms, title, categories = conjugate_strong(args) | | + | elseif conj_type == "pp" then | | + | forms, title, categories = conjugate_pp(args) | | elseif conj_type == "hebben" then | | elseif conj_type == "hebben" then | | forms, title, categories = conjugate_hebben(args) | | forms, title, categories = conjugate_hebben(args) | Line 150: | Line 152: | | title = title .. ", irregular" | | title = title .. ", irregular" | | end | | end | | + | | | + | return forms, title, categories | | + | end | | + | | | + | -- Conjugate a "preterite-present" verb | | + | function conjugate_pp(args) | | + | local forms = {} | | + | local categories = "[[Category:Dutch preterite-present verbs]]" | | + | local title = "preterite-present" | | + | | | + | local pres_stem = args[1] or error("The first parameter is missing") | | + | local pres_stemT = pres_stem .. (pres_stem:find("t$") and "" or "t") | | + | local pres_stemE = args[4] or ""; if pres_stemE == "" then pres_stemE = pres_stem .. "e" end | | + | | | + | local past_stem = args[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 error("The third parameter is missing") | | + | | | + | present(forms, pres_stem, pres_stemE) | | + | past(forms, past_stem, past_stemE, past_stemT) | | + | forms["past_ptc"] = past_ptc_stem | | | | | | return forms, title, categories | | return forms, title, categories | --[=[ This module contains functions for creating inflection tables for Dutch verbs. ]=]-- local export = {} -- The main entry point 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 = frame:preprocess("{{PAGENAME}}") NAMESPACE = frame:preprocess("{{NAMESPACE}}") local forms, title, categories if conj_type == "weak" then forms, title, categories = conjugate_weak(args) elseif conj_type == "weak-cht" then forms, title, categories = conjugate_weak_cht(args) elseif conj_type == "strong" then forms, title, categories = conjugate_strong(args) elseif conj_type == "pp" then forms, title, categories = conjugate_pp(args) elseif conj_type == "hebben" then forms, title, categories = conjugate_hebben(args) elseif conj_type == "willen" then forms, title, categories = conjugate_willen(args) elseif conj_type == "zijn" then forms, title, categories = conjugate_zijn(args) else error("Unknown conjugation type") end local pref = args["pref"] or "" if pref ~= "" then categories = categories .. "[[Category:Dutch prefixed verbs]]" title = title .. ", prefixed" end local sep = args["sep"] or "" if sep ~= "" then categories = categories .. "[[Category:Dutch separable verbs]]" title = title .. ", separable" end sep_pref(forms, sep, pref) linkify(forms) forms["past_ptc"] = "(" .. link_form(args["aux"] or "hebben") .. ") " .. forms["past_ptc"] return make_table(forms, title, sep ~= "") .. (NAMESPACE == "" and categories or "") end -- Conjugate a weak verb function conjugate_weak(args) local forms = {} local categories = "[[Category:Dutch weak verbs]]" local title = "weak" local pres_stem = args[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 categories = categories .. "[[Category: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 categories = categories .. "[[Category:Dutch irregular weak verbs]]" title = title .. ", irregular" end return forms, title, categories end -- Conjugate a weak verb with a past tense in -cht function conjugate_weak_cht(args) local forms = {} local categories = "[[Category:Dutch weak verbs (-cht)]]" local title = "weak with past in ''-cht''" local pres_stem = args[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 error("The third parameter is missing")) .. "cht" local past_stemE = past_stem .. "e" present(forms, pres_stem, pres_stemE) past(forms, past_stem, past_stemE, past_stem) forms["past_ptc"] = past_stem return forms, title, categories end -- Conjugate a strong verb function conjugate_strong(args) local forms = {} local class = args["class"] or ""; if class ~= "" then class = " class " .. class end local categories = "[[Category:Dutch" .. class .. " strong verbs]]" local title = "strong" .. class local pres_stem = args[1] or error("The first parameter is missing") local pres_stemT = pres_stem .. (pres_stem:find("t$") and "" or "t") local pres_stemE = args[4] or ""; if pres_stemE == "" then pres_stemE = pres_stem .. "e" end local past_stem = args[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 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 categories = categories .. "[[Category: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"} categories = categories .. "[[Category:Dutch irregular strong verbs]]" title = title .. ", irregular" elseif pres_stem == "snijd" then forms["pres_indc_1sg"] = {"snij", "snijd"} forms["impr_sg"] = {"snij", "snijd"} categories = categories .. "[[Category: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 categories = categories .. "[[Category:Dutch irregular strong verbs]]" title = title .. ", irregular" end return forms, title, categories end -- Conjugate a "preterite-present" verb function conjugate_pp(args) local forms = {} local categories = "[[Category:Dutch preterite-present verbs]]" local title = "preterite-present" local pres_stem = args[1] or error("The first parameter is missing") local pres_stemT = pres_stem .. (pres_stem:find("t$") and "" or "t") local pres_stemE = args[4] or ""; if pres_stemE == "" then pres_stemE = pres_stem .. "e" end local past_stem = args[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 error("The third parameter is missing") present(forms, pres_stem, pres_stemE) past(forms, past_stem, past_stemE, past_stemT) forms["past_ptc"] = past_ptc_stem return forms, title, categories end -- Conjugate the irregular verb "hebben" function conjugate_hebben(args) local forms = {} local categories = "[[Category: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 -- Conjugate the irregular verb "willen" function conjugate_willen(args) local forms = {} local forms2 = {} local categories = "[[Category: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 -- Conjugate the irregular verb "zijn" function conjugate_zijn(args) local forms = {} local categories = "[[Category: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 -- 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 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 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 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") forms["pres_ptc"] = sepHyphen .. pref .. forms["pres_ptc"] if pref == "" then forms["past_ptc"] = sep .. "ge" .. forms["past_ptc"]:gsub("^e", "ë"):gsub("^i", "ï"):gsub("^u", "ü") else forms["past_ptc"] = sepHyphen .. pref .. forms["past_ptc"] 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 a link out of a form, or show a dash if empty. function link_form(form) if type(form) == "table" then for n, subform in pairs(form) do form[n] = link_form(subform) end return table.concat(form, ", ") else if form ~= "" then if form == PAGENAME then return "<span lang=\"nl\">[[" .. form .. "]]</span>" else return "<span lang=\"nl\">[[" .. form .. "#Dutch|" .. form .. "]]</span>" end else return "—" end end end -- Make links out of all forms in a table function linkify(forms) for key, form in pairs(forms) do forms[key] = link_form(form) end end -- Make the table function make_table(forms, title, sep) return [=[ <div class="NavFrame" style="width: ]=] .. (sep 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"] .. [=[ ]=] .. (sep and [=[|- style="background: #E6E6FF;" | | colspan="2" style="font-weight: bold;" | [[main clause]] | colspan="2" style="font-weight: bold;" | [[subordinate clause]] |- style="background: #E6E6FF;" | | style="width: 25%; font-weight: bold" | [[present tense]] | style="width: 25%; font-weight: bold" | [[past tense]] | style="width: 25%; font-weight: bold" | [[present tense]] | style="width: 25%; font-weight: bold" | [[past tense]]]=] or [=[ |- style="background: #E6E6FF;" | | style="width: 50%; font-weight: bold" | [[present tense]] | style="width: 50%; font-weight: bold" | [[past tense]]]=]) .. [=[ |- style="background: #F2F2FF;" ! style="background: #CCCCFF;" | [[first-person|1st person]] [[singular]] | ]=] .. (sep 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 person]] [[singular]] | ]=] .. (sep 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 person]] [[singular|sing.]] (<span lang="nl">[[u#Dutch|u]]</span>) | ]=] .. (sep 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 person]] [[singular|sing.]] (<span lang="nl">[[gij#Dutch|gij]]</span>) | ]=] .. (sep 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 person]] [[singular]] | ]=] .. (sep 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]] | ]=] .. (sep 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" |]=] .. (sep and [=[ || colspan="2" |]=] or "") .. [=[ |- style="background: #F2F2FF;" ! style="background: #CCCCFF;" | [[subjunctive]] [[singular|sing.]]<sup>1</sup> | ]=] .. (sep 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]] [[plural|plur.]]<sup>1</sup> | ]=] .. (sep 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" |]=] .. (sep and [=[ || rowspan="5" colspan="2" |]=] or "") .. [=[ |- style="background: #F2F2FF;" ! style="background: #CCCCFF;" | [[imperative]] [[singular|sing.]] | ]=] .. forms["impr_sg"] .. [=[ | rowspan="2" style="background: #E6E6FF;" | |- style="background: #F2F2FF;" ! style="background: #CCCCFF;" | [[imperative]] [[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 return export -- [[Category:Modules]] | |