Springe nei ynhâld

Module:nl-adjectives

Ut Wikiwurdboek
De neikommende dokumintaasje stiet op Module:nl-adjectives/dokumintaasje. [bewurkje]

Oernommen fan en:Module:nl-adjectives.

Oerset:

  • foutmeldingen
  • nammeromte
  • tabelopskriften/keppelings

Oanpast:

  • ûntbrekkende CSS classes derút/ferfongen
  • tabel: part nei list, CSS
  • accel útskeakele

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 "adjective"
	
	if not inflections[infl_type] then
		error("Unbekend type bûging '" .. infl_type .. "'")
	end
	
	local data = {forms = {}, categories = {}, comparable = true}
	local args = require("Module:parameters").process(frame:getParent().args, inflections[infl_type].params)
	
	-- Generate the forms
	inflections[infl_type].func(args, data)
	
	return make_table(data)
end

inflections["adjective"] = {
	params = {
		[1] = {},
		[2] = {},
		[3] = {},
		["pred"] = {},
		["part"] = {},
	},
	func = function(args, data)
		-- Get parameters
		local pred = args["pred"]
		local infl = args[1]
		local part = args["part"]
		local comd = args[2]
		local supd = args[3]
		
		if comd == "-" then
			data.comparable = false
		end
		
		local base = mw.title.getCurrentTitle().nsText == "Berjocht" 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"] = {pred}
		data.forms["indef|m|and|f|s"] = {infl}
		data.forms["indef|n|s"] = {base}
		data.forms["indef|p"] = {infl}
		data.forms["def"] = {infl}
		data.forms["par"] = {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("[^eio]en$") or base:find("[aeou]ien$") then infl_comd = comd end
			local part_comd = export.make_partitive(comd)
			
			data.forms["pred|comd"] = {comd}
			data.forms["indef|m|and|f|s|comd"] = {infl_comd}
			data.forms["indef|n|s|comd"] = {comd}
			data.forms["indef|p|comd"] = {infl_comd}
			data.forms["def|comd"] = {infl_comd}
			data.forms["par|comd"] = {part_comd}
			
			-- Superlative degree
			supd = supd or export.make_superlative(base, part)
			local infl_supd = export.make_inflected(supd)
			
			data.forms["pred|supd"] = {"het [[" .. supd .. "]]", "het [[" .. infl_supd .. "]]"}
			data.forms["indef|m|and|f|s|supd"] = {infl_supd}
			data.forms["indef|n|s|supd"] = {infl_supd}
			data.forms["indef|p|supd"] = {infl_supd}
			data.forms["def|supd"] = {infl_supd}
			data.forms["par|supd"] = nil
		end
	end
}

inflections["pres-ptc"] = {
	params = {
		[1] = {},
	},
	func = function(args, data)
		data.comparable = false
		inflections["adjective"].func(args, data)
		
		-- The predicative form of the present participle can have -e too,
		-- in sentences like "Hij is stervende".
		table.insert(data.forms["pred"], data.forms["indef|m|and|f|s"][1])
	end
}

inflections["past-ptc"] = {
	params = {
		[1] = {},
	},
	func = function(args, data)
		data.comparable = false
		inflections["adjective"].func(args, data)
	end
}

inflections["irregular"] = {
	params = {
		[1] = {},
	},
	func = function(args, data)
		local base = args[1] or (mw.title.getCurrentTitle().nsText == "Berjocht" and "veel" or mw.title.getCurrentTitle().text)
		
		if irregular[base] then
			irregular[base](data)
		else
			error("Unbekend ûnregelmjittich eigenskipswurd '" .. base .. "'.")
		end
	end
}

irregular["veel"] = function(data)
	data.forms["pred"] = {"veel"}
	data.forms["indef|m|and|f|s"] = {"veel"}
	data.forms["indef|n|s"] = {"veel"}
	data.forms["indef|p"] = {"veel"}
	data.forms["def"] = {"vele"}
	data.forms["par"] = nil
	
	data.forms["pred|comd"] = {"meer"}
	data.forms["indef|m|and|f|s|comd"] = {"meer"}
	data.forms["indef|n|s|comd"] = {"meer"}
	data.forms["indef|p|comd"] = {"meer"}
	data.forms["def|comd"] = nil
	data.forms["par|comd"] = nil
	
	data.forms["pred|supd"] = {"het [[meest]]", "het [[meeste]]"}
	data.forms["indef|m|and|f|s|supd"] = nil
	data.forms["indef|n|s|supd"] = nil
	data.forms["indef|p|supd"] = nil
	data.forms["def|supd"] = {"meeste"}
	data.forms["par|supd"] = nil
end

irregular["weinig"] = function(data)
	data.forms["pred"] = {"weinig"}
	data.forms["mfsg"] = {"weinig"}
	data.forms["nsg"] = {"weinig"}
	data.forms["pl"] = {"weinig"}
	data.forms["def"] = {"weinige"}
	data.forms["part"] = nil
	
	data.forms["pred|comd"] = {"minder"}
	data.forms["indef|m|and|f|s|comd"] = {"minder"}
	data.forms["indef|n|s|comd"] = {"minder"}
	data.forms["indef|p|comd"] = {"minder"}
	data.forms["def|comd"] = nil
	data.forms["par|comd"] = nil
	
	data.forms["pred|supd"] = {"het [[minst]]", "het [[minste]]"}
	data.forms["indef|m|and|f|s|supd"] = {"minste"}
	data.forms["indef|n|s|supd"] = {"minste"}
	data.forms["indef|p|supd"] = {"minste"}
	data.forms["def|supd"] = {"minste"}
	data.forms["par|supd"] = 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("[^eio]en$") or base:find("[aeou]ien$") or base:find("[^eio]e$") then
		return base
	-- Adjectives ending in certain digraphs get a diaeresis
	elseif base:find("[eio]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("[^aeiou][aiouy]$") 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("[eë]$") 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("[iï]de$") then
		return base:gsub("([iï])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)
		-- N.f.t. (sjoch https://en.wiktionary.org/w/index.php?title=Wiktionary:ACCEL) - PiefPafPier
		local accel = false
		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[param]
		
		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 = [=[
{| class="mw-collapsible mw-collapsed" style="background-color: #d4d4ff /* fallback */; background-image: linear-gradient(to bottom right, #e0e0ff, #c7c7ff); text-align: center; float: right;"
|- style="background-color: #e0e0ff;"
| colspan="5" style="border-bottom: 1px dotted gray; text-align: left;" | Alle bûgings fan <b>{{{lemma}}}</b>{{{info}}}
|- style="background-color: #c7c7ff;"
! colspan="2" |
! style="min-width: 12em;" | [[grûntrime]]]=] .. (data.comparable and [=[

! style="min-width: 12em;" | [[meartrime]]
! style="min-width: 12em;" | [[measttrime]]]=] or "") .. [=[

|- style="background-color: #e0e0ff;"
! style="background-color: #c7c7ff;" colspan="2" | [[predikatyf]]/[[bywurdlik]]
| {{{pred}}}]=] .. (data.comparable and " || {{{pred|comd}}} || {{{pred|supd}}}" or "") .. [=[

|- height: 0.5em"
| colspan="3" |]=] .. (data.comparable and " || colspan=\"2\" |" or "") .. [=[

|- style="background-color: #e0e0ff;"
! style="background-color: #c7c7ff;" rowspan="3" | [[ûnbeskaat]]
! style="background-color: #c7c7ff;" | [[manlik|m.]]/[[froulik|f.]]&nbsp;[[inkeldtal|ink.]]
| {{{indef|m|and|f|s}}}]=] .. (data.comparable and " || {{{indef|m|and|f|s|comd}}} || {{{indef|m|and|f|s|supd}}}" or "") .. [=[

|- style="background-color: #e0e0ff;"
! style="background-color: #c7c7ff;" | [[ûnsidich|û.]]&nbsp;[[inkeldtal|ink.]]
| {{{indef|n|s}}}]=] .. (data.comparable and " || {{{indef|n|s|comd}}} || {{{indef|n|s|supd}}}" or "") .. [=[

|- style="background-color: #e0e0ff;"
! style="background-color: #c7c7ff;" | [[meartal]]
| {{{indef|p}}}]=] .. (data.comparable and " || {{{indef|p|comd}}} || {{{indef|p|supd}}}" or "") .. [=[

|- style="background-color: #e0e0ff;"
! style="background-color: #c7c7ff;" colspan="2" | [[beskaat]]
| {{{def}}}]=] .. (data.comparable and " || {{{def|comd}}} || {{{def|supd}}}" or "") .. [=[

|- height: 0.5em"
| colspan="3" |]=] .. (data.comparable and " || colspan=\"2\" |" or "") .. [=[

|-
! style="background-color: #c7c7ff;" colspan="2" | [[partityf]]
| style="background-color: #e0e0ff;" | {{{par}}}]=] .. (data.comparable and " || style=\"background-color: #e0e0ff;\" | {{{par|comd}}} ||" or "") .. [=[

|}<div style="float: left;">
* Net bûgd: {{{!indef|n|s}}}.
* Bûgd: {{{!indef|m|and|f|s}}}.</div><div style="clear: both;"></div>]=]
	
	return mw.ustring.gsub(wikicode, "{{{([#!]?[a-z0-9|]+)}}}", repl) .. require("Module:utilities").format_categories(data.categories, lang)
end

return export