This module is used for the {{nl-decl-adj}}
template. It's also used by {{nl-adj}}
to generate comparative and superlative forms.
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 or "adjective"
if not inflections then
error("Unknown inflection type '" .. infl_type .. "'")
end
local data = {forms = {}, categories = {}, comparable = true, comparitive = true}
local args = require("Module:parameters").process(frame:getParent().args, inflections.params)
-- Generate the forms
inflections.func(args, data)
return make_table(data)
end
inflections = {
params = {
= {},
= {},
= {},
= {},
= {},
},
func = function(args, data)
-- Get parameters
local pred = args
local infl = args
local part = args
local comd = args
local supd = args
if comd == "-" then
data.comparable = false
end
local base = mw.title.getCurrentTitle().nsText == "Template" and "-" or mw.title.getCurrentTitle().text
-- Positive degree
if pred == "-" then
pred = nil
else
pred = pred or base
end
infl = infl or export.make_inflected(base)
if part == "-" then
part = nil
else
part = part or export.make_partitive(base)
end
data.forms = {pred}
data.forms = {infl}
data.forms = {base}
data.forms = {infl}
data.forms = {infl}
data.forms = {part}
-- Participles never have comparative and superlative forms.
-- If they do, then they're probably really adjectives.
if data.comparable then
-- Comparative degree
comd = comd or export.make_comparative(base, infl)
local infl_comd = export.make_inflected(comd); if base:find("en$") or base:find("ien$") then infl_comd = comd end
local part_comd = export.make_partitive(comd)
data.forms = {comd}
data.forms = {infl_comd}
data.forms = {comd}
data.forms = {infl_comd}
data.forms = {infl_comd}
data.forms = {part_comd}
-- Superlative degree
supd = supd or export.make_superlative(base, part)
local infl_supd = export.make_inflected(supd)
data.forms = {"het ]", "het ]"}
data.forms = {infl_supd}
data.forms = {infl_supd}
data.forms = {infl_supd}
data.forms = {infl_supd}
data.forms = nil
end
end
}
inflections = {
params = {
= {},
},
func = function(args, data)
data.comparable = false
data.comparitive = false
inflections.func(args, data)
-- The predicative form of the present participle can have -e too,
-- in sentences like "Hij is stervende".
table.insert(data.forms, data.forms)
end
}
inflections = {
params = {
= {},
},
func = function(args, data)
data.comparable = false
data.comparitive = false
inflections.func(args, data)
end
}
inflections = {
params = {
= {},
},
func = function(args, data)
local base = args or (mw.title.getCurrentTitle().nsText == "Template" and "veel" or mw.title.getCurrentTitle().text)
if irregular then
irregular(data)
else
error("Unknown irregular adjective '" .. base .. "'.")
end
end
}
irregular = function(data)
data.forms = {"veel"}
data.forms = {"veel"}
data.forms = {"veel"}
data.forms = {"veel"}
data.forms = {"vele"}
data.forms = nil
data.forms = {"meer"}
data.forms = {"meer"}
data.forms = {"meer"}
data.forms = {"meer"}
data.forms = nil
data.forms = nil
data.forms = {"het ]", "het ]"}
data.forms = nil
data.forms = nil
data.forms = nil
data.forms = {"meeste"}
data.forms = nil
end
irregular = function(data)
data.forms = {"weinig"}
data.forms = {"weinig"}
data.forms = {"weinig"}
data.forms = {"weinig"}
data.forms = {"weinige"}
data.forms = nil
data.forms = {"minder"}
data.forms = {"minder"}
data.forms = {"minder"}
data.forms = {"minder"}
data.forms = nil
data.forms = nil
data.forms = {"het ]", "het ]"}
data.forms = {"minste"}
data.forms = {"minste"}
data.forms = {"minste"}
data.forms = {"minste"}
data.forms = nil
end
-- Four functions to create various forms.
-- These are exported, because Module:nl-headword also uses them to create
-- comparative and superlative forms.
function export.make_inflected(base)
-- Adjectives ending in unstressed -en or -e get no extra -e.
if base:find("en$") or base:find("ien$") or base:find("e$") then
return base
-- Adjectives ending in certain digraphs get a diaeresis
elseif base:find("e$") then
return base .. "ë"
else
return base .. "e"
end
end
function export.make_partitive(base)
-- Adjectives ending in a sibilant do not get an extra -s
if base:find("s$") or base:find("sch$") or base:find("x$") or base:find("sj$") or base:find("sh$") then
return base
-- Adjectives ending in a long vowel get an apostrophe before the -s
elseif base:find("$") then
return base .. "'s"
else
return base .. "s"
end
end
function export.make_comparative(base, inflected)
if not inflected then
inflected = export.make_inflected(base)
end
-- Adjectives ending in -r get an extra -d- in the comparative,
-- disregarding the inflected form
if base:find("r$") then
return base .. "der"
-- If the inflected form does not end in -e, add it
elseif not inflected:find("$") then
return inflected .. "er"
else
return inflected .. "r"
end
end
function export.make_superlative(base, partitive)
if not partitive then
partitive = export.make_partitive(base)
end
-- Adjectives in -ide have a superlative -iedst
if base:find("de$") then
return base:gsub("()de$", "%1ed") .. "st"
elseif partitive then
return partitive .. "t"
else
return base .. "st"
end
end
-- Make the table
function make_table(data)
local function repl(param)
local accel = true
local no_store = false
if param == "lemma" then
return require("Module:links").full_link({lang = lang, alt = mw.title.getCurrentTitle().text}, "term")
elseif param == "info" then
return data.title and " (" .. data.title .. ")" or ""
elseif string.sub(param, 1, 1) == "!" then
no_store = true
param = string.sub(param, 2)
elseif string.sub(param, 1, 1) == "#" then
accel = false
param = string.sub(param, 2)
end
local forms = data.forms
if not forms then
return "—"
end
local ret = {}
for key, subform in ipairs(forms) do
table.insert(ret, require("Module:links").full_link({lang = lang, term = subform, accel = accel and {form = param, lemma = data.lemma, no_store = no_store} or nil}))
end
return table.concat(ret, "<br/>")
end
local wikicode = [=[
{| style="border: 1px solid var(--wikt-palette-indigo-3, #CCCCFF); text-align: center; line-height: 125%;" class="inflection-table vsSwitcher" data-toggle-category="declension" cellspacing="1" cellpadding="3"
|- style="background: var(--wikt-palette-indigo-3, #CCCCFF);"
! colspan="5" class="vsToggleElement" style="text-align: left" | Declension of {{{lemma}}}{{{info}}}
|- class="vsShow" style="background: var(--wikt-palette-indigo-0, #F2F2FF);"
! style="background: var(--wikt-palette-indigo-2, #CCCCFF);" | uninflected
| style="min-width: 12em;" | {{{!indef|n|s}}}
|- class="vsShow" style="background: var(--wikt-palette-indigo-0, #F2F2FF);"
! style="background: var(--wikt-palette-indigo-2, #CCCCFF);" | inflected
| {{{!indef|m|and|f|s}}}]=] .. (data.comparitive and [=[
|- class="vsShow" style="background: var(--wikt-palette-indigo-0, #F2F2FF);"
! style="background: var(--wikt-palette-indigo-2, #CCCCFF);" | comparative
| {{{!indef|n|s|comd}}}]=] or "") .. [=[
|- class="vsHide" style="background: var(--wikt-palette-indigo-2, #CCCCFF);"
| colspan="2" |
! style="min-width: 12em;" | ]]=] .. (data.comparable and [=[
! style="min-width: 12em;" | ]
! style="min-width: 12em;" | ]]=] or "") .. [=[
|- class="vsHide" style="background: var(--wikt-palette-indigo-0, #F2F2FF);"
! style="background: var(--wikt-palette-indigo-2, #CCCCFF);" colspan="2" | ]/]
| {{{pred}}}]=] .. (data.comparable and " || {{{pred|comd}}} || {{{pred|supd}}}" or "") .. [=[
|- class="vsHide" style="background: var(--wikt-palette-indigo-0, #F2F2FF);"
! style="background: var(--wikt-palette-indigo-2, #CCCCFF);" rowspan="3" | ]
! style="background: var(--wikt-palette-indigo-2, #CCCCFF);" | ]/] ]
| {{{indef|m|and|f|s}}}]=] .. (data.comparable and " || {{{indef|m|and|f|s|comd}}} || {{{indef|m|and|f|s|supd}}}" or "") .. [=[
|- class="vsHide" style="background: var(--wikt-palette-indigo-0, #F2F2FF);"
! style="background: var(--wikt-palette-indigo-2, #CCCCFF);" | ] ]
| {{{indef|n|s}}}]=] .. (data.comparable and " || {{{indef|n|s|comd}}} || {{{indef|n|s|supd}}}" or "") .. [=[
|- class="vsHide" style="background: var(--wikt-palette-indigo-0, #F2F2FF);"
! style="background: var(--wikt-palette-indigo-2, #CCCCFF);" | ]
| {{{indef|p}}}]=] .. (data.comparable and " || {{{indef|p|comd}}} || {{{indef|p|supd}}}" or "") .. [=[
|- class="vsHide" style="background: var(--wikt-palette-indigo-0, #F2F2FF);"
! style="background: var(--wikt-palette-indigo-2, #CCCCFF);" colspan="2" | ]
| {{{def}}}]=] .. (data.comparable and " || {{{def|comd}}} || {{{def|supd}}}" or "") .. [=[
|- class="vsHide" style="background: var(--wikt-palette-indigo-0, #F2F2FF);"
! style="background: var(--wikt-palette-indigo-2, #CCCCFF);" colspan="2" | ]
| {{{par}}}]=] .. (data.comparable and " || {{{par|comd}}} || {{{par|supd}}}" or "") .. [=[
|}]=]
return mw.ustring.gsub(wikicode, "{{{(?+)}}}", repl) .. require("Module:utilities").format_categories(data.categories, lang)
end
return export