Edukira joan

Modulu:eu

Wiktionarytik

Documentation for this module may be created at Modulu:eu/dok

local extra = require("Module:extra")

local export = {}

local t = {
	["label"] = {
		["animation"] = {
			["a"] = "bizidun",
			["i"] = "bizigabe",
		},
		["case"] = {
			["abl"] = "ablatibo",
			["abs"] = "absolutibo",
			["all"] = "adlatibo",
			["ben"] = "destinatibo",
			["cau"] = "motibatibo",
			["com"] = "soziatibo",
			["dat"] = "datibo",
			["des"] = "adlatibo destinatibo",
			["dir"] = "hubiltze adlatibo",
			["erg"] = "ergatibo",
			["gen"] = "genitibo",
			["ine"] = "inesibo",
			["ins"] = "instrumental",
			["loc"] = "lokatibo",
			["par"] = "partitibo",
			["pro"] = "prolatibo",
			["ter"] = "muga-adlatibo",
		},
		["degree"] = {
			["c"] = "konparatibo",
			["e"] = "gehiegizko",
			["p"] = "positibo",
			["s"] = "superlatibo",
		},
		["gender"] = {
			["f"] = "femenino",
			["m"] = "maskulino",
			["n"] = "neutro",
		},
		["number"] = {
			["i"] = "mugagabe",
			["p"] = "plural",
			["s"] = "singular",
		},
		["propriarity"] = {
			["i"] = "impropio",
			["p"] = "propio",
		},
	},
	["suffix"] = {
		["case"] = {
			["abl"] = {
				["a"] = "engandik",
				["i"] = "tik",
			},
			["abs"] = "",
			["all"] = {
				["a"] = "engana",
				["i"] = "ra",
			},
			["ben"] = "entzat",
			["cau"] = "engatik",
			["com"] = "ekin",
			["dat"] = "i",
			["des"] = {
				["a"] = "enganako",
				["i"] = "rako",
			},
			["dir"] = {
				["a"] = "enganantz",
				["i"] = "rantz",
			},
			["erg"] = "k",
			["gen"] = "en",
			["ine"] = {
				["a"] = "engan",
				["i"] = "n",
			},
			["ins"] = "z",
			["loc"] = {
				["i"] = "ko",
			},
			["par"] = "ik",
			["pro"] = "tzat",
			["ter"] = {
				["a"] = "enganaino",
				["i"] = "raino",
			},
		},
	}
}

function export.getAdjektive(frame)
	return "euskal"
end

function export.getAnimation(frame)
	local tArg = extra.table.cover(frame.getParent and frame:getParent().args, frame.args)
	return (tArg[1] and	t.label.animation[tArg[1]] or "")
end

function export.getCase(frame)
	local tArg = extra.table.cover(frame.getParent and frame:getParent().args, frame.args)
	return (tArg[1] and	t.label.case[tArg[1]] or "")
end

function export.getDegree(frame)
	local tArg = extra.table.cover(frame.getParent and frame:getParent().args, frame.args)
	return (tArg[1] and	t.label.degree[tArg[1]] or "")
end

function export.getGender(frame)
	local tArg = extra.table.cover(frame.getParent and frame:getParent().args, frame.args)
	return (tArg[1] and	t.label.gender[tArg[1]] or "")
end

function export.getInflectedNounPhrase(frame)
	local sRes = ""
	local tArg = extra.table.cover(frame.getParent and frame:getParent().args, frame.args)
	tArg["lemma"] = (
		tArg[1] or
		tArg["lema"] or
		tArg["lemma"] or
		"‑"
	)
	tArg["propriarity"] = (
		tArg[2] or
		tArg["propiotasuna"] or
		tArg["propiotasun"] or
		tArg["propriarity"]
	)
	tArg["propriarity"] = extra.table.find(extra.table.listindex(
		t.label.propriarity
	), tArg["propriarity"]) and tArg["propriarity"] or "i"
	tArg["animation"] = (
		tArg[3] or
		tArg["bizitasuna"] or
		tArg["bizitasun"] or
		tArg["animation"]
	)
	tArg["animation"] = extra.table.find(extra.table.listindex(
		t.label.animation
	), tArg["animation"]) and tArg["animation"] or "i"
	tArg["case"] = (
		tArg[4] or
		tArg["kasua"] or
		tArg["kasu"] or
		tArg["case"]
	)
	tArg["case"] = extra.string.find(
		tArg["case"],
		{t.label.case, t.label.number},
		1,
		false,
		true
	)
	tArg["number"] = (
		tArg[5] or
		tArg["numeroa"] or
		tArg["numero"] or
		tArg["number"]
	)
	tArg["number"] = extra.string.find(
		tArg["number"],
		{t.label.number},
		1,
		false,
		true
	)[1]
	tArg["number"] = (
		tArg["number"] and tArg["number"][2] or
		tArg["case"][2] and tArg["case"][2][2] or
		"i"
	)
	tArg["number"] = extra.table.find(extra.table.listindex(
		t.label.number
	), tArg["number"]) and tArg["number"] or "i"
	tArg["case"] = tArg["case"][1] and tArg["case"][1][2] or "abs"
	tArg["selection"] = tonumber(
		tArg[6] or
		tArg["aukera"] or
		tArg["selection"]
	) or 1
	sRes = tArg["lemma"]
	if tArg["case"] == "abs" or sRes == "‑" then
		if tArg["number"] == "i" or sRes == "‑" then
			return sRes
		end
		if string.sub(sRes, -1) == "r" then
			sRes = sRes .. "r"
		end
		if string.sub(sRes, -1) == "a" then
			sRes = string.sub(sRes, 1, -2)
		end
		if tArg["propriarity"] == "i" then
			sRes = sRes .. "a"
			if tArg["number"] == "p" then
				sRes = sRes .. "k"
			end
			return sRes
		end
		return ({"‑"})[tArg["selection"]]
	end
	if tArg["case"] == "pro" then
		if tArg["number"] == "i" then
			if string.sub(sRes, -2) == "tz" then
				sRes = string.sub(sRes, 1, -3)
			end
			if string.sub(sRes, -1) == "t" then
				sRes = string.sub(sRes, 1, -2)
			end
			sRes = sRes .. t.suffix.case[tArg["case"]]
			return sRes
		end
		return ({"‑"})[tArg["selection"]]
	end
	if string.sub(sRes, -1) == "r" then
		sRes = sRes .. "r"
	end
	if (
		string.sub(sRes, -1) == "a" and
		not tArg["number"] == "i"
	) then
		sRes = string.sub(sRes, 1, -2)
	end
	if tArg["case"] == "par" then
		if tArg["number"] == "i" then
			if string.match(sRes, "[aeiou]", -1) then
				sRes = sRes .. "r"
			end
			sRes = sRes .. t.suffix.case[tArg["case"]]
			return sRes
		end
		return ({"‑"})[tArg["selection"]]
	end
	if type(t.suffix.case[tArg["case"]]) == type({}) then
		local tInfix = {
			["i"] = {
				["a"] = {
					["i"] = (
						string.match(sRes, "[aeiou]", -1) and "r" or
						""
					),
					["p"] = "",
					["s"] = "ar",
				},
				["i"] = {
					["i"] = (
						string.match(sRes, "[aeiou]", -1) and "ta" or
						"eta"
					),
					["p"] = "eta",
					["s"] = (
						tArg["case"] == "ine" and (
							string.match(tArg["lemma"], "[ar]", -1) and "a" or
							"ea"
						) or
						string.match(tArg["lemma"], "[a]", -1) and "a" or
						string.match(tArg["lemma"], "[eiou]", -1) and "" or
						"e"
					),
				},
			},
			["p"] = {
				["a"] = {
					["i"] = (
						string.match(sRes, "[aeiou]", -1) and "r" or
						""
					),
				},
				["i"] = {
					["i"] = (
						string.match(sRes, "[a]", -1) and "ta" or
						string.match(sRes, "[r]", -1) and (
							tArg["case"] == "ine" and "a" or
							"e"
						) or
						string.match(sRes, "[eiou]", -1) and "" or
						"e"
					),
				},
			},
		}
		if (
			tInfix[tArg["propriarity"]][tArg["animation"]][tArg["number"]] and
			t.suffix.case[tArg["case"]][tArg["animation"]]
		) then
			sRes = (
				sRes ..
				tInfix[tArg["propriarity"]][tArg["animation"]][tArg["number"]] ..
				t.suffix.case[tArg["case"]][tArg["animation"]]
			)
			return sRes
		end
		return ({"‑"})[tArg["selection"]]
	end
	if tArg["case"] == "dat" then
		sRes = sRes .. ({
			["i"] = (
				string.match(sRes, "[aeiou]", -1) and "r" or
				""
			),
			["p"] = "e",
			["s"] = "ar",
		})[tArg["number"]] .. t.suffix.case[tArg["case"]]
		return sRes
	end
	if extra.table.find({"erg", "ins"}, tArg["case"]) then
		sRes = sRes .. ({
			["i"] = (
				string.match(sRes, "[aeiou]", -1) and "" or
				"e"
			),
			["p"] = "e",
			["s"] = "a",
		})[tArg["number"]] .. t.suffix.case[tArg["case"]]
		return sRes
	end
	if extra.table.find({"ben", "cau", "com", "gen"}, tArg["case"]) then
		sRes = sRes .. ({
			["i"] = (
				string.match(sRes, "[aeiou]", -1) and "r" or
				""
			),
			["p"] = "",
			["s"] = "ar",
		})[tArg["number"]] .. t.suffix.case[tArg["case"]]
		return sRes
	end
	return ({"‑"})[tArg["selection"]]
end

function export.getName(frame)
	return "Euskara"
end

function export.getNativeAdjektive(frame)
	return "euskal"
end

function export.getNativeName(frame)
	return "Euskara"
end

function export.getNumber(frame)
	local tArg = extra.table.cover(frame.getParent and frame:getParent().args, frame.args)
	return (tArg[1] and	t.label.number[tArg[1]] or "")
end

function export.getPropriarity(frame)
	local tArg = extra.table.cover(frame.getParent and frame:getParent().args, frame.args)
	return (tArg[1] and	t.label.propriarity[tArg[1]] or "")
end

function export.getSymbol(frame)
	local tArg = extra.table.cover(frame.getParent and frame:getParent().args, frame.args)
	return (
		"[[Irudi:Flag of the Basque Country.svg|border|" .. tostring(tonumber(
			tArg[1] or tArg["neurria"] or tArg["neurri"] or tArg["size"]
		) or 60) .. "px]]"
	)
end

return export