Module:eu-verb-form

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

This module is not to be directly used. It is used by Template:eu-verb form of, see there for usage.


local export = {}
local m_links = require("Module:links")
local m_utilities = require("Module:utilities")

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

function export.verb_form(frame)
	local params = {
		[1] = {required = true},
		[2] = {required = true},
		[3] = {},
		[4] = {},
		
		["gloss"] = {},
		["t"] = {alias_of = "gloss"},
		["nodot"] = {type = "boolean"},
	}	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local text = ""
	local nocat = true
	local cats = {}
	local dot = "."
	if args.nodot == true then
		dot = ""
	end

	--throw an error if the arguments 3/4 are being used with non-finite forms
	if (args[2] == "impfpar" or args[2] == "fpar" or args[2] == "vn" or args[2] == "short" or args[2] == "mall" or args[2] == "fall") and (args[3] or args[4]) then
		error("The parameters 3 and 4 are not used with non-finite or allocutive forms")
	end
	
	--process the person parameters
	local nor = ""
	local nori = ""
	local nork = ""
	local nor_l = ""
	local nori_l = ""
	local nork_l = ""
	if args[2] == "nor" or args[2] == "nor-nori" or args[2] == "nor-nork" or args[2] == "nor-nori-nork" then
		if args[3] then
			person_arguments = mw.text.split(args[3], " ")
		else
			error("Please provide a person paramter.")
		end
	end
	if (args[2] == "nor" and #person_arguments ~= 1) or (args[2] == "nor-nori" and #person_arguments ~= 2) or (args[2] == "nor-nori-nork" and #person_arguments ~= 3) then
			error("Invalid person parameter.")
	end
	if args[2] == "nor" or args[2] == "nor-nori" then --process the "nor" parameter in nor and nor-nori verbs
		nor = person_arguments[1]
		if nor == "ni" then
			nor_l = "First-person singular (" .. m_links.full_link({term = "ni", lang = lang}, "term") .. ")"
		elseif nor == "hi" then
			nor_l = "Informal second-person singular (" .. m_links.full_link({term = "hi", lang = lang}, "term") .. ")"
		elseif nor == "hura" then
			nor_l = "Third-person singular (" .. m_links.full_link({term = "hura", lang = lang}, "term") .. ")"
		elseif nor == "gu" then
			nor_l = "First-person plural (" .. m_links.full_link({term = "gu", lang = lang}, "term") .. ")"
		elseif nor == "zu" then
			nor_l = "Second-person singular (" .. m_links.full_link({term = "zu", lang = lang}, "term") .. ")"
		elseif nor == "zuek" then
			nor_l = "Second-person plural (" .. m_links.full_link({term = "zuek", lang = lang}, "term") .. ")"
		elseif nor == "haiek" then
			nor_l = "Third-person plural (" .. m_links.full_link({term = "haiek", lang = lang}, "term") .. ")"
		else
			error("Invalid nor argument.")
		end
	end
	if args[2] == "nor-nori" or args[2] == "nor-nori-nork" then --process the "nori" parameter
		nori = person_arguments[2]
		if nori == "niri" then
			nori_l = "first-person singular (" .. m_links.full_link({term = "niri", lang = lang}, "term") .. ")"
		elseif nori == "hiri" then
			nori_l = "informal second-person singular (" .. m_links.full_link({term = "hiri", lang = lang}, "term") .. ")"
		elseif nori == "hirim" then
			nori_l = "informal second-person singular masculine (" .. m_links.full_link({term = "hiri", lang = lang}, "term") .. ")"
		elseif nori == "hirif" then
			nori_l = "informal second-person singular feminine (" .. m_links.full_link({term = "hiri", lang = lang}, "term") .. ")"
		elseif nori == "hari" then
			nori_l = "third-person singular (" .. m_links.full_link({term = "hari", lang = lang}, "term") .. ")"
		elseif nori == "guri" then
			nori_l = "first-person plural (" .. m_links.full_link({term = "guri", lang = lang}, "term") .. ")"
		elseif nori == "zuri" then
			nori_l = "second-person singular (" .. m_links.full_link({term = "zuri", lang = lang}, "term") .. ")"
		elseif nori == "zuei" then
			nori_l = "second-person plural (" .. m_links.full_link({term = "zuei", lang = lang}, "term") .. ")"
		elseif nori == "haiei" then
			nori_l = "third-person plural (" .. m_links.full_link({term = "haiei", lang = lang}, "term") .. ")"
		else
			error("Invalid nori argument.")
		end
	end
	if args[2] == "nor-nork" or args[2] == "nor-nori-nork" then --process the "nork" parameter and the "nor" parameter in nor-nork and nor-nori-nork verbs
		nork = person_arguments[1]
		if args[2] == "nor-nork" then
			nor = person_arguments[2]
		else
			nor = person_arguments[3]
		end
		if nork == "nik" then
			nork_l = "First-person singular (" .. m_links.full_link({term = "nik", lang = lang}, "term") .. ")"
		elseif nork == "hik" then
			nork_l = "Informal second-person singular (" .. m_links.full_link({term = "hik", lang = lang}, "term") .. ")"
		elseif nork == "hikm" then
			nork_l = "Informal second-person singular masculine (" .. m_links.full_link({term = "hik", lang = lang}, "term") .. ")"
		elseif nork == "hikf" then
			nork_l = "Informal second-person singular feminine (" .. m_links.full_link({term = "hik", lang = lang}, "term") .. ")"
		elseif nork == "hark" then
			nork_l = "Third-person singular (" .. m_links.full_link({term = "hark", lang = lang}, "term") .. ")"
		elseif nork == "guk" then
			nork_l = "First-person plural (" .. m_links.full_link({term = "guk", lang = lang}, "term") .. ")"
		elseif nork == "zuk" then
			nork_l = "Second-person singular (" .. m_links.full_link({term = "zuk", lang = lang}, "term") .. ")"
		elseif nork == "zuek" then
			nork_l = "Second-person plural (" .. m_links.full_link({term = "zuek", lang = lang}, "term") .. ")"
		elseif nork == "haiek" then
			nork_l = "Third-person plural (" .. m_links.full_link({term = "haiek", lang = lang}, "term") .. ")"
		else
			error("Invalid nork argument.")
		end
		if nor == "ni" then
			nor_l = "first-person singular (" .. m_links.full_link({term = "ni", lang = lang}, "term") .. ")"
		elseif nor == "hi" then
			nor_l = "informal second-person singular (" .. m_links.full_link({term = "hi", lang = lang}, "term") .. ")"
		elseif nor == "hura" then
			nor_l = "third-person singular (" .. m_links.full_link({term = "hura", lang = lang}, "term") .. ")"
		elseif nor == "gu" then
			nor_l = "first-person plural (" .. m_links.full_link({term = "gu", lang = lang}, "term") .. ")"
		elseif nor == "zu" then
			nor_l = "second-person singular (" .. m_links.full_link({term = "zu", lang = lang}, "term") .. ")"
		elseif nor == "zuek" then
			nor_l = "second-person plural (" .. m_links.full_link({term = "zuek", lang = lang}, "term") .. ")"
		elseif nor == "haiek" then
			nor_l = "third-person plural (" .. m_links.full_link({term = "haiek", lang = lang}, "term") .. ")"
		else
			error("Invalid nor argument.")
		end
	end
	
	--generate the text
	if args[2] == "impfpar" then
		text = "Imperfect participle of"
		nocat = false
		cats = {"Basque imperfect participles"}
	elseif args[2] == "fpar" then
		text = "Future participle of"
		nocat = false
		cats = {"Basque future participles"}
	elseif args[2] == "short" then
		text = "Short form of"
		nocat = false
		cats = {"Basque short verb forms"}
	elseif args[2] == "vn" then
		text = "Verbal noun of"
		nocat = false
		cats = {"Basque verbal nouns"}
	elseif args[2] == "mall" then
		text = "Masculine allocutive form of"
		nocat = false
		cats = {"Basque masculine allocutive verb forms"}
	elseif args[2] == "fall" then
		text = "Feminine allocutive form of"
		nocat = false
		cats = {"Basque feminine allocutive verb forms"}
	elseif args[2] == "nor" then
		text = nor_l
	elseif args[2] == "nor-nori" then
		text = nor_l .. ", taking " .. nori_l .. " as indirect object,"
	elseif args[2] == "nor-nork" then
		text = nork_l .. ", taking " .. nor_l .. " as direct object,"
	elseif args[2] == "nor-nori-nork" then
		text = nork_l .. ", taking " .. nori_l .. " as indirect object and " .. nor_l .. " as direct object,"
	else
		error("Invalid verb form type.")
	end
	
	--add tenses
	if args[2] == "nor" or args[2] == "nor-nori" or args[2] == "nor-nork" or args[2] == "nor-nori-nork" then
		if args[4] == "presi" then
			text = text .. " present indicative form of"
		elseif args[4] == "pasti" then
			text = text .. " past indicative form of"
		elseif args[4] == "cond" then
			text = text .. " conditional indicative form of"
		elseif args[4] == "hcons" then
			text = text .. " hypothetic consequential indicative form of"
		elseif args[4] == "pcons" then
			text = text .. " past consequential indicative form of"
		elseif args[4] == "futi" then --forms like dateke (archaic or dialectal, not found in most learning materials)
			text = text .. " future indicative form of"
		elseif args[4] == "presp" then
			text = text .. " present potential form of"
		elseif args[4] == "pastp" then
			text = text .. " past potential form of"
		elseif args[4] == "hypp" then
			text = text .. " hypothetic potential form of"
		elseif args[4] == "ccond" then --forms like banadi (archaic, not found in most learning materials)
			text = text .. " close conditional potential form of"
		elseif args[4] == "dcond" then --forms like banendi (archaic, not found in most learning materials)
			text = text .. " distal conditional potential form of"
		elseif args[4] == "press" then
			text = text .. " present subjunctive form of"
		elseif args[4] == "hyps" then
			text = text .. " hypothetic subjunctive form of"
		elseif args[4] == "pasts" then
			text = text .. " past subjunctive form of"
		elseif args[4] == "imp" then
			text = text .. " present imperative form of"
		else
			error("Please provide a valid tense/mood.")
		end			
	end
	
	local lemma_obj = {lang = lang, term = args[1], gloss = args["gloss"]}
	return require("Module:form of").format_form_of{text = text, lemmas = {lemma_obj}, lemma_face = "term", posttext = dot} .. (nocat and "" or m_utilities.format_categories(cats, lang))
end

return export