Module:fy-verbs

From Wiktionary, the free dictionary
Jump to navigation Jump to search

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 lang = require("Module:languages").getByCode("fy")

local export = {}

--Functions for the inflections
local irregverbs = {}

function export.weak1(frame)
	local params = {
		[1] = {required = true, default = "{{{1}}}"},
		[2] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	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")
	
	local data = {forms = {}, info = "weak class 1", categories = {lang:getCanonicalName() .. " class 1 weak verbs"}}
	
	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}
	
	return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end

function export.weak2(frame)
	local params = {
		[1] = {required = true, default = "{{{1}}}"},
		[2] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local stem_pres = args[1]
	local stem_pres_e = args[2] or stem_pres .. "e"
	
	local data = {forms = {}, info = "weak class 2", categories = {lang:getCanonicalName() .. " class 2 weak verbs"}}
	
	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}
	
	return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end


function export.strong(frame)
	local params = {
		[1] = {required = true, default = "{{{1}}}"},
		[2] = {},
		[3] = {required = true, default = "{{{3}}}"},
		[4] = {},
		[5] = {required = true, default = "{{{5}}}", list = "past_ptcp"},
		["class"] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	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"
	
	local data = {forms = {}, info = "strong" .. (args["class"] and " class " .. args["class"] or ""), categories = {lang:getCanonicalName() .. (args["class"] and " class " .. args["class"] or "") .. " strong verbs"}}
	
	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]
	
	return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end

function export.irregular(frame)
	local params = {
		[1] = {required = true, default = "wêze"},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local data = {forms = irregverbs[args[1]].forms, info = "Irregular", categories = {lang:getCanonicalName() .. " irregular verbs"}}
	
	-- Check if verb is suppletive
	if irregverbs[args[1]].supl then
		data.info = "Irregular (Suppletive)"
		table.insert(data.categories,lang:getCanonicalName().. " suppletive verbs")
	end
	
	return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end

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

-- Make the table
function make_table(data)
	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 #CCCCFF;\" cellspacing=\"1\" cellpadding=\"3\"")
	table.insert(wikicode, "|- style=\"background: #CCCCFF;\"")
	table.insert(wikicode, "! colspan=\"3\" class=\"vsToggleElement\" style=\"text-align: left\" | {{{info}}}")
	
	-- Principal parts
	table.insert(wikicode, "|- class=\"vsShow\" style=\"background: #F2F2FF;\"")
	table.insert(wikicode, "! style=\"background: #CCCCFF; min-width: 10em;\" | infinitive")
	table.insert(wikicode, "| style=\"min-width: 12em;\" | {{{inf}}}")
	
	table.insert(wikicode, "|- class=\"vsShow\" style=\"background: #F2F2FF;\"")
	table.insert(wikicode, "! style=\"background: #CCCCFF;\" | 3rd singular past")
	table.insert(wikicode, "| {{{3sg_past_indc}}}")
	
	table.insert(wikicode, "|- class=\"vsShow\" style=\"background: #F2F2FF;\"")
	table.insert(wikicode, "! style=\"background: #CCCCFF;\" | past participle")
	table.insert(wikicode, "| {{{past_ptcp}}}")
	
	-- Infinitives
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
	table.insert(wikicode, "! style=\"background: #CCCCFF; min-width: 10em;\" | infinitive")
	table.insert(wikicode, "| colspan=\"2\" | {{{inf}}}")
	
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
	table.insert(wikicode, "! style=\"background: #CCCCFF;\" | long infinitive")
	table.insert(wikicode, "| colspan=\"2\" | {{{inf_long}}}")
	
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
	table.insert(wikicode, "! style=\"background: #CCCCFF;\" | gerund")
	table.insert(wikicode, "| colspan=\"4\" | {{{gerund}}}")
	
	--Auxiliary
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
	table.insert(wikicode, "! style=\"background: #CCCCFF;\" | auxiliary")
	table.insert(wikicode, "| colspan=\"4\" | {{{aux_verb}}}")
	
	-- Indicative
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #E6E6FF;\"")
	table.insert(wikicode, "! indicative")
	table.insert(wikicode, "! style=\"min-width: 12em;\" | present tense")
	table.insert(wikicode, "! style=\"min-width: 12em;\" | past tense")
	
	for _, row in ipairs(rows) do
		table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
		table.insert(wikicode, "! style=\"background: #CCCCFF\" | " .. names[row])
		table.insert(wikicode, "| {{{" .. row .. "_pres_indc}}}")
		table.insert(wikicode, "| {{{" .. row .. "_past_indc}}}")
	end
	
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #E6E6FF; height: 0.5em\"")
	table.insert(wikicode, "|")
	table.insert(wikicode, "| colspan=\"2\" |")
	
	-- Imperative
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
	table.insert(wikicode, "! style=\"background: #CCCCFF;\" | imperative")
	table.insert(wikicode, "| {{{impr}}}")
	table.insert(wikicode, "| style=\"background: #E6E6FF;\" |")
	
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #E6E6FF; height: 0.5em\"")
	table.insert(wikicode, "|")
	table.insert(wikicode, "| colspan=\"2\" |")
	
	-- Participles
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
	table.insert(wikicode, "! style=\"background: #CCCCFF;\" | participles")
	table.insert(wikicode, "| {{{pres_ptcp}}}")
	table.insert(wikicode, "| {{{past_ptcp}}}")
	
	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