Jump to content

Module:fy-verbs

From Wiktionary, the free dictionary

This module contains functions for creating inflection tables for West Frisian verbs. It implements the tables for {{fy-infl-verb-irreg}}, {{fy-infl-verb-st}}, {{fy-infl-verb-wk1}}, and {{fy-infl-verb-wk2}}.


local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local m_table = require("Module:table")

local lang = require("Module:languages").getByCode("fy")

local export = {}

--Functions for the inflections
local inflections = {}
local irregverbs = {}

local hyphenated = m_table.listToSet {
	-- double vowel
	"aa", "ee", "ii", "oo", "uu", "yy",
	-- diphthongs from [[AP:pron:fy]]
	"au", "ou", "ei", "ij", "oi", "ui", "ea", "eo", "eu", "ie", "oa", "oe", "ue",
	-- other
	"ai", "io", "iy",
}

function export.show(frame)
	local infl_type = frame.args[1] or error("Inflection type has not been specified. Please pass parameter 1 to the module invocation.")
	
	if not inflections[infl_type] then
		error("Unknown inflection type '" .. infl_type .. "'")
	end
	
	params = {
		["sep"] = {}
	}
	
	for key, val in pairs(inflections[infl_type].params) do
		params[key] = val
	end
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local data = {forms = {}, info = nil, categories = {}}
	
	inflections[infl_type].func(args, data)
	
	local sep = args["sep"]
	if sep then
		add_sep(args, data)
		data.info = data.info .. ", separable"
		table.insert(data.categories, lang:getCanonicalName() .. " separable verbs")
		table.insert(data.categories, lang:getCanonicalName() .. " separable verbs with " .. sep)
	end
	
	return make_table(data, args["sep"]) .. m_utilities.format_categories(data.categories, lang)
end

-- Add the separable part to all the verb forms
function add_sep(args, data)
	sep = args["sep"]

	-- Add main clause forms
	local mainforms = {}
	local vowel_cluster
	
	for key, form in pairs(data.forms) do
		if (key:find("_pres_") or key:find("_past_")) and not key:find("_ptc$") then
			mainforms[key .. "_main"] = mw.clone(form)
		end
	end
	
	for key, form in pairs(mainforms) do
		data.forms[key] = form
	end
	
	-- Add separable part to forms
	for key, form in pairs(data.forms) do
		if key:find("_main$") or key:find("^impr") then
			-- For main-clause finite forms, add the separable part after the form, separated by a space
			for i, subform in ipairs(data.forms[key]) do
				data.forms[key][i] = data.forms[key][i] .. " " .. sep
			end
		else
			-- For all other forms, add the separable part before the form, with no space
			for i, subform in ipairs(data.forms[key]) do
				vowel_cluster = sep:sub(-1) .. subform:sub(1, 1)
				if (hyphenated[vowel_cluster]) then
					subform = sep .. "-" .. subform
				else
					subform = sep .. subform
				end
				
				data.forms[key][i] = subform
			end
		end
	end
end

inflections["weak1"] = {
	params = {
		[1] = {required = true, default = "{{{1}}}"},
		[2] = {},
	},
	func = function(args, data)
		local stem_pres = args[1]
		local stem_pres_e = args[2] or stem_pres .. "e"
		local stem_past = stem_pres_e:find("[dt]e$") and stem_pres or (stem_pres .. (stem_pres_e:find("[cfhkpqsx]e$") and "t" or "d"))
		local stem_past_e = stem_pres_e:find("[dt]e$") and stem_pres_e or (stem_pres .. (stem_pres_e:find("[cfhkpqsx]e$") and "t" or "d") .. "e")
		
		table.insert(data.categories, lang:getCanonicalName() .. " class 1 weak verbs")
		data.info = "weak class 1"
		
		data.forms["1sg_pres_indc"] = {stem_pres}
		data.forms["2sg_pres_indc"] = {stem_pres .. (mw.ustring.find(stem_pres, "s$") and "" or "s") .. "t"}
		data.forms["3sg_pres_indc"] = {stem_pres .. (mw.ustring.find(stem_pres, "t$") and "" or "t")}
		data.forms["pl_pres_indc"]  = {stem_pres_e}
		
		data.forms["1sg_past_indc"] = {stem_past_e}
		data.forms["2sg_past_indc"] = {stem_past_e .. "st"}
		data.forms["3sg_past_indc"] = {stem_past_e}
		data.forms["pl_past_indc"]  = {stem_past_e .. "n"}
		
		data.forms["impr"] = {stem_pres}
		
		data.forms["inf"]       = {stem_pres_e}
		data.forms["inf_long"]  = {stem_pres_e .. "n"}
		data.forms["pres_ptcp"] = {stem_pres_e .. "nd"}
		data.forms["past_ptcp"] = {stem_past, stem_past == stem_pres and stem_past_e .. "n" or nil}
	end
}

inflections["weak2"] = {
	params = {
		[1] = {required = true, default = "{{{1}}}"},
		[2] = {},
	},
	func = function(args, data)
		local stem_pres = args[1]
		local stem_pres_e = args[2] or stem_pres .. "e"
		
		table.insert(data.categories, lang:getCanonicalName() .. " class 2 weak verbs")
		data.info = "weak class 2"
		
		data.forms["1sg_pres_indc"] = {stem_pres .. "je"}
		data.forms["2sg_pres_indc"] = {stem_pres_e .. "st"}
		data.forms["3sg_pres_indc"] = {stem_pres_e .. "t"}
		data.forms["pl_pres_indc"]  = {stem_pres .. "je"}
		
		data.forms["1sg_past_indc"] = {stem_pres_e}
		data.forms["2sg_past_indc"] = {stem_pres_e .. "st"}
		data.forms["3sg_past_indc"] = {stem_pres_e}
		data.forms["pl_past_indc"]  = {stem_pres_e .. "n"}
		
		data.forms["impr"] = {stem_pres .. "je"}
		
		data.forms["inf"]       = {stem_pres .. "je"}
		data.forms["inf_long"]  = {stem_pres .. "jen"}
		data.forms["pres_ptcp"] = {stem_pres .. "jend"}
		data.forms["past_ptcp"] = {stem_pres_e}
	end
}

inflections["strong"] = {
	params = {
		[1] = {required = true, default = "{{{1}}}"},
		[2] = {},
		[3] = {required = true, default = "{{{3}}}"},
		[4] = {},
		[5] = {required = true, default = "{{{5}}}", list = "past_ptcp"},
		["class"] = {},
	},
	func = function(args, data)
		local stem_pres = args[1]
		local stem_pres_e = args[2] or stem_pres .. "e"
		local stem_past = args[3]
		local stem_past_e = args[4] or stem_past .. "e"
		
		table.insert(data.categories, lang:getCanonicalName() .. (args["class"] and " class " .. args["class"] or "") .. " strong verbs")
		data.info = "strong" .. (args["class"] and " class " .. args["class"] or "")
		
		data.forms["1sg_pres_indc"] = {stem_pres}
		data.forms["2sg_pres_indc"] = {stem_pres .. (mw.ustring.find(stem_pres, "s$") and "" or "s") .. "t"}
		data.forms["3sg_pres_indc"] = {stem_pres .. (mw.ustring.find(stem_pres, "t$") and "" or "t")}
		data.forms["pl_pres_indc"]  = {stem_pres_e}
		
		data.forms["1sg_past_indc"] = {stem_past}
		data.forms["2sg_past_indc"] = {stem_past .. (mw.ustring.find(stem_pres, "s$") and "" or "s") .. "t"}
		data.forms["3sg_past_indc"] = {stem_past}
		data.forms["pl_past_indc"]  = {stem_past_e .. "n"}
		
		data.forms["impr"] = {stem_pres}
		
		data.forms["inf"]       = {stem_pres_e}
		data.forms["inf_long"]  = {stem_pres_e .. "n"}
		data.forms["pres_ptcp"] = {stem_pres_e .. "nd"}
		data.forms["past_ptcp"] = args[5]
	end
}

inflections["irregular"] = {
	params = {
		[1] = {required = true, default = "wêze"},
	},
	func = function(args, data)
		data.forms = irregverbs[args[1]].forms
		table.insert(data.categories, lang:getCanonicalName() .. " irregular verbs")
		data.info = "Irregular"
		
		-- Check if verb is suppletive
		if irregverbs[args[1]].supl then
			data.info = "Irregular (Suppletive)"
			table.insert(data.categories,lang:getCanonicalName().. " suppletive verbs")
		end
	end
}

local names = {
	["1sg"] = "1st singular",
	["2sg"] = "2nd singular",
	["3sg"] = "3rd singular",
	["pl"] = "plural",
}

-- Make the table
function make_table(data, hasSep)
	local function repl(param)
		if param == "info" then
			return mw.getContentLanguage():ucfirst(data.info or "")
		end
		
		local forms = data.forms[param]
		
		if param == "gerund" then
			forms = data.forms["inf_long"]
		end
		
		--Return hawwe if regular
		if param == "aux_verb" and not forms then return "[[hawwe]]" end
		
		if not forms then
			return "—"
		end
		
		local ret = {}
		
		for key, form in ipairs(forms) do
			table.insert(ret, m_links.full_link({lang = lang, term = form, genders = (param == "gerund" and {"n"} or nil)}))
		end
		
		return table.concat(ret, ", ")
	end
	
	local rows = {"1sg", "2sg", "3sg", "pl"}
	
	local wikicode = {}
	
	table.insert(wikicode, "{| class=\"inflection-table vsSwitcher\" data-toggle-category=\"inflection\" style=\"border:1px solid var(--wikt-palette-indigo-3, #CCCCFF);\" cellspacing=\"1\" cellpadding=\"3\"")
	table.insert(wikicode, "|- style=\"background: var(--wikt-palette-indigo-3, #CCCCFF);\"")
	table.insert(wikicode, "! colspan=\"5\" class=\"vsToggleElement\" style=\"text-align: left\" | {{{info}}}")
	
	-- Principal parts
	table.insert(wikicode, "|- class=\"vsShow\" style=\"background: var(--wikt-palette-indigo-0, #F2F2FF);\"")
	table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo-2, #CCCCFF); min-width: 10em;\" | infinitive")
	table.insert(wikicode, "| style=\"min-width: 12em;\" | {{{inf}}}")
	
	table.insert(wikicode, "|- class=\"vsShow\" style=\"background: var(--wikt-palette-indigo-0, #F2F2FF);\"")
	table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo-2, #CCCCFF);\" | 3rd singular past")
	if hasSep then
		table.insert(wikicode, "| {{{3sg_past_indc_main}}}")
	else
		table.insert(wikicode, "| {{{3sg_past_indc}}}")
	end
	
	table.insert(wikicode, "|- class=\"vsShow\" style=\"background: var(--wikt-palette-indigo-0, #F2F2FF);\"")
	table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo-2, #CCCCFF);\" | past participle")
	table.insert(wikicode, "| {{{past_ptcp}}}")
	
	-- Infinitives
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo-0, #F2F2FF);\"")
	table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo-2, #CCCCFF); min-width: 10em;\" | infinitive")
	table.insert(wikicode, "| colspan=\"4\" | {{{inf}}}")
	
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo-0, #F2F2FF);\"")
	table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo-2, #CCCCFF);\" | long infinitive")
	table.insert(wikicode, "| colspan=\"4\" | {{{inf_long}}}")
	
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo-0, #F2F2FF);\"")
	table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo-2, #CCCCFF);\" | gerund")
	table.insert(wikicode, "| colspan=\"4\" | {{{gerund}}}")
	
	--Auxiliary
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo-0, #F2F2FF);\"")
	table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo-2, #CCCCFF);\" | auxiliary")
	table.insert(wikicode, "| colspan=\"4\" | {{{aux_verb}}}")
	
	-- Indicative
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo-1, #E6E6FF);\"")
	if hasSep then
		table.insert(wikicode, "|")
		table.insert(wikicode, "! colspan=\"2\" style=\"min-width: 12em;\" | main clause")
		table.insert(wikicode, "! colspan=\"2\" style=\"min-width: 12em;\" | subordinate clause")
		table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo-1, #E6E6FF);\"")
		table.insert(wikicode, "! indicative")
		table.insert(wikicode, "! style=\"min-width: 12em;\" | present tense")
		table.insert(wikicode, "! style=\"min-width: 12em;\" | past tense")
		table.insert(wikicode, "! style=\"min-width: 12em;\" | present tense")
		table.insert(wikicode, "! style=\"min-width: 12em;\" | past tense")
	else
		table.insert(wikicode, "! indicative")
		table.insert(wikicode, "! style=\"min-width: 12em;\" | present tense")
		table.insert(wikicode, "! style=\"min-width: 12em;\" | past tense")
	end
	
	for _, row in ipairs(rows) do
		table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo-0, #F2F2FF);\"")
		table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo-2, #CCCCFF)\" | " .. names[row])
		if hasSep then
			table.insert(wikicode, "| {{{" .. row .. "_pres_indc_main}}}")
			table.insert(wikicode, "| {{{" .. row .. "_past_indc_main}}}")
		end
		table.insert(wikicode, "| {{{" .. row .. "_pres_indc}}}")
		table.insert(wikicode, "| {{{" .. row .. "_past_indc}}}")
	end
	
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo-1, #E6E6FF); height: 0.5em\"")
	table.insert(wikicode, "|")
	table.insert(wikicode, "| colspan=\"4\" |")
	
	-- Imperative
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo-0, #F2F2FF);\"")
	table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo-2, #CCCCFF);\" | imperative")
	table.insert(wikicode, "| {{{impr}}}")
	table.insert(wikicode, "| colspan=\"3\" style=\"background: var(--wikt-palette-indigo-1, #E6E6FF);\" | ")
	
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo-1, #E6E6FF); height: 0.5em\"")
	table.insert(wikicode, "|")
	table.insert(wikicode, "| colspan=\"4\" |")
	
	-- Participles
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo-0, #F2F2FF);\"")
	table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo-2, #CCCCFF);\" | participles")
	table.insert(wikicode, "| {{{pres_ptcp}}}")
	table.insert(wikicode, "| {{{past_ptcp}}}")
	
	if hasSep then
		table.insert(wikicode, "| colspan=\"2\" style=\"background: var(--wikt-palette-indigo-1, #E6E6FF);\" | ")
	end
	
	table.insert(wikicode, "|}")
	
	wikicode = table.concat(wikicode, "\n")
	
	return mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)
end

--[=[
	*** IRREGULAR VERB CONJUGATIONS ***
]=]--
irregverbs["wêze"] = {
	forms = {
		["1sg_pres_indc"] = {"bin"},
		["2sg_pres_indc"] = {"bist"},
		["3sg_pres_indc"] = {"is"},
		["pl_pres_indc"]  = {"binne"},
	
		["1sg_past_indc"] = {"wie"},
		["2sg_past_indc"] = {"wiest"},
		["3sg_past_indc"] = {"wie"},
		["pl_past_indc"]  = {"wienen"},
	
		["impr"] = {"wês"},
	
		["inf"]       = {"wêze"},
		["inf_long"]  = {"wêzen"},
		["pres_ptcp"] = {"wêzend", "wêzende"},
		["past_ptcp"] = {"west"},
		["aux_verb"] = {"hawwe"}
	},
	supl = true
}
irregverbs["gean"] = {
	forms = {
		["1sg_pres_indc"] = {"gean"},
		["2sg_pres_indc"] = {"giest"},
		["3sg_pres_indc"] = {"giet"},
		["pl_pres_indc"]  = {"geane"},
	
		["1sg_past_indc"] = {"gie", "gong", "gyng"},
		["2sg_past_indc"] = {"giest", "gongst", "gyngst"},
		["3sg_past_indc"] = {"gie", "gong", "gyng"},
		["pl_past_indc"]  = {"gongen", "gienen", "gyngen"},
	
		["impr"] = {"gean"},
	
		["inf"]       = {"gean"},
		["inf_long"]  = {"gean"},
		["pres_ptcp"] = {"geanend", "geanende"},
		["past_ptcp"] = {"gien", "gongen"},
		["aux_verb"] = {"wêze"}
	},
	supl = true
}
irregverbs["hawwe"] = {
	forms = {
		["1sg_pres_indc"] = {"ha", "haw"},
		["2sg_pres_indc"] = {"hast"},
		["3sg_pres_indc"] = {"hat"},
		["pl_pres_indc"]  = {"hawwe"},
	
		["1sg_past_indc"] = {"hie"},
		["2sg_past_indc"] = {"hiest"},
		["3sg_past_indc"] = {"hie"},
		["pl_past_indc"]  = {"hiene", "hienen"},
	
		["impr"] = {"haw"},
	
		["inf"]       = {"hawwe"},
		["inf_long"]  = {"hawwen"},
		["pres_ptcp"] = {"hawwend", "hawwende"},
		["past_ptcp"] = {"hân"},
		["aux_verb"] = {"hawwe"}
	}
}
irregverbs["jaan"] = {
	forms = {
		["1sg_pres_indc"] = {"jou"},
		["2sg_pres_indc"] = {"joust"},
		["3sg_pres_indc"] = {"jout"},
		["pl_pres_indc"]  = {"jouwe"},
	
		["1sg_past_indc"] = {"joech"},
		["2sg_past_indc"] = {"joechst"},
		["3sg_past_indc"] = {"joech"},
		["pl_past_indc"]  = {"joegen"},
	
		["impr"] = {"jou"},
	
		["inf"]       = {"jaan"},
		["inf_long"]  = {"jaan"},
		["pres_ptcp"] = {"jaand", "jaande"},
		["past_ptcp"] = {"jûn"},
		["aux_verb"] = {"hawwe"}
	}
}
irregverbs["dwaan"] = {
	forms = {
		["1sg_pres_indc"] = {"doch"},
		["2sg_pres_indc"] = {"dochst"},
		["3sg_pres_indc"] = {"docht"},
		["pl_pres_indc"]  = {"dogge"},
	
		["1sg_past_indc"] = {"die", "diich", "dyng"},
		["2sg_past_indc"] = {"diest", "diichst", "dyngst"},
		["3sg_past_indc"] = {"die", "diich", "dyng"},
		["pl_past_indc"]  = {"dienen", "diene", "digen", "dyngen"},
	
		["impr"] = {"doch"},
	
		["inf"]       = {"dwaan"},
		["inf_long"]  = {"dwaan"},
		["pres_ptcp"] = {"dwaand", "dwaande"},
		["past_ptcp"] = {"dien"},
		["aux_verb"] = {"hawwe"}
	}
}
irregverbs["stean"] = {
	forms = {
		["1sg_pres_indc"] = {"stean"},
		["2sg_pres_indc"] = {"stiest"},
		["3sg_pres_indc"] = {"stiet"},
		["pl_pres_indc"]  = {"steane"},
	
		["1sg_past_indc"] = {"stie"},
		["2sg_past_indc"] = {"stiest"},
		["3sg_past_indc"] = {"stie"},
		["pl_past_indc"]  = {"stiene"},
	
		["impr"] = {"stean"},
	
		["inf"]       = {"stean"},
		["inf_long"]  = {"stean"},
		["pres_ptcp"] = {"steand", "steande"},
		["past_ptcp"] = {"stien"},
		["aux_verb"] = {"hawwe"}
	}
}
irregverbs["sizze"] = {
	forms = {
		["1sg_pres_indc"] = {"sis"},
		["2sg_pres_indc"] = {"seist", "seiste"},
		["3sg_pres_indc"] = {"seit"},
		["pl_pres_indc"]  = {"sizze"},
	
		["1sg_past_indc"] = {"sei"},
		["2sg_past_indc"] = {"seist", "seiste", "seidest", "seideste"},
		["3sg_past_indc"] = {"sei"},
		["pl_past_indc"]  = {"seine", "seiene", "seien", "seinen"},
	
		["impr"] = {"sis"},
	
		["inf"]       = {"sizze"},
		["inf_long"]  = {"sizzen"},
		["pres_ptcp"] = {"sizzend"},
		["past_ptcp"] = {"sein"},
		["aux_verb"] = {"hawwe"}
	}
}

return export