Module:nl-verbs: difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
No edit summary |
on the template-page itself, don't raise an error if the first parameter is missing -- testing |
||
Line 5: | Line 5: | ||
PAGENAME = frame:preprocess("{{PAGENAME}}") |
PAGENAME = frame:preprocess("{{PAGENAME}}") |
||
NAMESPACE = frame:preprocess("{{NAMESPACE}}") |
NAMESPACE = frame:preprocess("{{NAMESPACE}}") |
||
if NAMESPACE == 'Template' and PAGENAME == 'nl-conj-wk' and not args[1] then |
|||
args = { |
|||
'{{{1}}}', |
|||
'{{{2}}}', |
|||
dt = '{{{dt}}}' |
|||
} |
|||
end |
|||
local pres_stem = args[1] or error("The first parameter is missing") |
local pres_stem = args[1] or error("The first parameter is missing") |
Revision as of 04:54, 21 February 2013
- The following documentation is located at Module:nl-verbs/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module contains functions for creating inflection tables for Dutch verbs.
local export = {}
function export.weak(frame)
local args = frame:getParent().args
PAGENAME = frame:preprocess("{{PAGENAME}}")
NAMESPACE = frame:preprocess("{{NAMESPACE}}")
if NAMESPACE == 'Template' and PAGENAME == 'nl-conj-wk' and not args[1] then
args = {
'{{{1}}}',
'{{{2}}}',
dt = '{{{dt}}}'
}
end
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[2] or ""; if pres_stemE == "" then pres_stemE = pres_stem .. "e" end
local dt = args["dt"] or ""; if dt == "" then if pres_stemE:find("[cfhkpqsx]e$") then dt = "t" else dt = "d" end end
local past_stem = pres_stem .. dt
local forms = {}
-- Present indicative
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"] = pres_stemE .. "n"
-- Past indicative
forms["past_indc_sg"] = past_stem .. "e"
forms["past_indc_gij"] = past_stem .. "e"
forms["past_indc_pl"] = past_stem .. "en"
-- Subjunctive
forms["pres_subj_sg"] = pres_stemE
forms["past_subj_sg"] = past_stem .. "e"
-- Imperative
forms["impr_sg"] = pres_stem
forms["impr_pl"] = pres_stemT
-- Participles
forms["pres_ptc"] = pres_stemE .. "nd"
forms["past_ptc"] = args[3] or "ge" .. pres_stem .. (pres_stem:find("[dt]$") and "" or dt)
local sep = args["sep"]
process_sep(forms, sep)
local title = "<span lang=\"nl\">" .. forms["pres_indc_pl"] .. "</span> (weak)"
local categories = "[[Category:Dutch weak verbs]]"
linkify(forms)
local aux = args["aux"] or "hebben"
local aux2 = args["aux2"]
forms["past_ptc"] = "(" .. link_form(aux) .. (aux2 and "/" .. link_form(aux2) or "") .. ") " .. forms["past_ptc"]
return make_table(forms, title, sep) .. (NAMESPACE == "" and categories or "")
end
function export.weak_cht(frame)
local args = frame:getParent().args
PAGENAME = frame:preprocess("{{PAGENAME}}")
NAMESPACE = frame:preprocess("{{NAMESPACE}}")
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[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 forms = {}
-- Present indicative
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"] = pres_stemE .. "n"
-- Past indicative
forms["past_indc_sg"] = past_stem
forms["past_indc_gij"] = past_stem
forms["past_indc_pl"] = past_stem .. "en"
-- Subjunctive
forms["pres_subj_sg"] = pres_stemE
forms["past_subj_sg"] = past_stem .. "e"
-- Imperative
forms["impr_sg"] = pres_stem
forms["impr_pl"] = pres_stemT
-- Participles
forms["pres_ptc"] = pres_stemE .. "nd"
forms["past_ptc"] = args[4] or "ge" .. past_stem
local sep = args["sep"]
process_sep(forms, sep)
local title = "<span lang=\"nl\">" .. forms["pres_indc_pl"] .. "</span> (weak with past in ''-cht'')"
local categories = "[[Category:Dutch weak verbs (-cht)]]"
linkify(forms)
local aux = args["aux"] or "hebben"
local aux2 = args["aux2"]
forms["past_ptc"] = "(" .. link_form(aux) .. (aux2 and "/" .. link_form(aux2) or "") .. ") " .. forms["past_ptc"]
return make_table(forms, title, sep) .. (NAMESPACE == "" and categories or "")
end
function export.strong(frame)
local args = frame:getParent().args
PAGENAME = frame:preprocess("{{PAGENAME}}")
NAMESPACE = frame:preprocess("{{NAMESPACE}}")
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 .. (pres_stem:find("t$") and "" or "t") end
local past_stemE = args[5] or ""; if past_stemE == "" then past_stemE = past_stem .. "e" end
local forms = {}
-- Present indicative
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"] = pres_stemE .. "n"
-- Past indicative
forms["past_indc_sg"] = past_stem
forms["past_indc_gij"] = past_stemT
forms["past_indc_pl"] = past_stemE .. "n"
-- Subjunctive
forms["pres_subj_sg"] = pres_stemE
forms["past_subj_sg"] = past_stemE
-- Imperative
forms["impr_sg"] = pres_stem
forms["impr_pl"] = pres_stemT
-- Participles
forms["pres_ptc"] = pres_stemE .. "nd"
forms["past_ptc"] = args[3] or error("The third parameter is missing")
local sep = args["sep"]
process_sep(forms, sep)
local class = args["class"]
local title = "<span lang=\"nl\">" .. forms["pres_indc_pl"] .. "</span> (strong" .. (class and " class " .. class or "") .. ")"
local categories = "[[Category:Dutch" .. (class and " class " .. class or "") .. " strong verbs]]"
linkify(forms)
local aux = args["aux"] or "hebben"
local aux2 = args["aux2"]
forms["past_ptc"] = "(" .. link_form(aux) .. (aux2 and "/" .. link_form(aux2) or "") .. ") " .. forms["past_ptc"]
return make_table(forms, title, sep) .. (NAMESPACE == "" and categories or "")
end
function export.mixed(frame)
local args = frame:getParent().args
PAGENAME = frame:preprocess("{{PAGENAME}}")
NAMESPACE = frame:preprocess("{{NAMESPACE}}")
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 .. (pres_stem:find("t$") and "" or "t") end
local past_stemE = args[5] or ""; if past_stemE == "" then past_stemE = past_stem .. "e" end
local forms = {}
-- Present indicative
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"] = pres_stemE .. "n"
-- Past indicative
forms["past_indc_sg"] = past_stem
forms["past_indc_gij"] = past_stemT
forms["past_indc_pl"] = past_stemE .. "n"
-- Subjunctive
forms["pres_subj_sg"] = pres_stemE
forms["past_subj_sg"] = past_stemE
-- Imperative
forms["impr_sg"] = pres_stem
forms["impr_pl"] = pres_stemT
-- Participles
forms["pres_ptc"] = pres_stemE .. "nd"
forms["past_ptc"] = args[3] or error("The third parameter is missing")
local sep = args["sep"]
process_sep(forms, sep)
local title = "<span lang=\"nl\">" .. forms["pres_indc_pl"] .. "</span> (mixed)"
local categories = "[[Category:Dutch mixed verbs]]"
linkify(forms)
local aux = args["aux"] or "hebben"
local aux2 = args["aux2"]
forms["past_ptc"] = "(" .. link_form(aux) .. (aux2 and "/" .. link_form(aux2) or "") .. ") " .. forms["past_ptc"]
return make_table(forms, title, sep) .. (NAMESPACE == "" and categories or "")
end
function process_sep(forms, sep)
if not sep then return end
local sepSuf = " " .. sep
forms["pres_indc_1sg_main"] = forms["pres_indc_1sg"] .. sepSuf ; forms["pres_indc_1sg"] = sep .. forms["pres_indc_1sg"]
forms["pres_indc_2sg_main"] = forms["pres_indc_2sg"] .. sepSuf ; forms["pres_indc_2sg"] = sep .. forms["pres_indc_2sg"]
forms["pres_indc_gij_main"] = forms["pres_indc_gij"] .. sepSuf ; forms["pres_indc_gij"] = sep .. forms["pres_indc_gij"]
forms["pres_indc_3sg_main"] = forms["pres_indc_3sg"] .. sepSuf ; forms["pres_indc_3sg"] = sep .. forms["pres_indc_3sg"]
forms["pres_indc_pl_main"] = forms["pres_indc_pl"] .. sepSuf ; forms["pres_indc_pl"] = sep .. forms["pres_indc_pl"]
forms["past_indc_sg_main"] = forms["past_indc_sg"] .. sepSuf ; forms["past_indc_sg"] = sep .. forms["past_indc_sg"]
forms["past_indc_gij_main"] = forms["past_indc_gij"] .. sepSuf ; forms["past_indc_gij"] = sep .. forms["past_indc_gij"]
forms["past_indc_pl_main"] = forms["past_indc_pl"] .. sepSuf ; forms["past_indc_pl"] = sep .. forms["past_indc_pl"]
forms["pres_subj_sg_main"] = forms["pres_subj_sg"] .. sepSuf ; forms["pres_subj_sg"] = sep .. forms["pres_subj_sg"]
forms["past_subj_sg_main"] = forms["past_subj_sg"] .. sepSuf ; forms["past_subj_sg"] = sep .. forms["past_subj_sg"]
forms["impr_sg"] = forms["impr_sg"] .. sepSuf
forms["impr_pl"] = forms["impr_pl"] .. sepSuf
forms["pres_ptc"] = sep .. forms["pres_ptc"]
forms["past_ptc"] = sep .. forms["past_ptc"]
end
function link_form(form)
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
function linkify(forms)
for key, form in pairs(forms) do
forms[key] = link_form(form)
end
end
function make_table(forms, title, sep)
return [=[
<div class="NavFrame" style="width: ]=] .. (sep and 72 or 42) .. [=[em;">
<div class="NavHead" style="background: #CCCCFF;">Conjugation of ]=] .. title .. [=[</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_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.]] ([[gij#Dutch|gij]])
| ]=] .. (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