انتقل إلى المحتوى

وحدة:category tree/lang/hu

من ويكاموس، القاموس الحر
local labels = {}
local handlers = {}

local m_strutils = require("Module:string utilities")
local m_table = require("Module:table")

local split = m_strutils.split
local unpack = unpack or table.unpack -- Lua 5.2 compatibility

labels["verbal participles"] = {
	description = "{{{langname}}} [[verbal participle]]s.",
	parents = {"participles"},
}

labels["terms taking arguments"] = {
	description = "{{{langname}}} terms taking arguments through governing [[postposition]]s or [[suffix]]es.",
	breadcrumb = "taking arguments",
	parents = {{name = "terms by lexical property", sort = "arguments"}},
}

local poses_taking_arguments = m_table.listToSet {
	"adjectives",
	"adverbs",
	"interjections",
	"nouns",
	"phrases",
	"postpositions",
	"verbs",
}

for plpos, _ in pairs(poses_taking_arguments) do
	labels[plpos .. " by argument"] = {
		description = "{{{langname}}} " .. plpos .. " categorized by the suffix(es) or postposition they govern in order to take an argument.",
		breadcrumb = "by argument",
		parents = {{name = plpos, sort = "arguments"}, {name = "terms taking arguments", sort = plpos}},
	}
end

for _, suffix_type_spec in ipairs {
	{"lative", "which indicate a motion to a location and answer the question {{m|hu|hova|t=to where}}."},
	{"locative", "which indicate a location and answer the question {{m|hu|hol|t=where}}."},
	{"separative", "which indicate a motion from a location and answer the question {{m|hu|honnan|t=from where}}."},
} do
	local suffix_type, desc = unpack(suffix_type_spec)
	for _, pos in ipairs {"terms", "verbs"} do
		local parents
		if pos == "terms" then
			parents = {{name = "terms taking arguments", sort = "*" .. suffix_type}}
		else
			parents = {{name = "terms taking " .. suffix_type .. " suffixes", sort = pos}}
			-- The raw category code had a comment <!-- the set of verbs that can take any, whichever out of -rÓl/-bÓl/-tÓl is a subset of verbs that can take this or that out of them -->
			for _, bol_tol_rol in ipairs {
				"-ból/-ből",
				"-ról/-ről",
				"-tól/-től"
			} do
				table.insert(parents, {name = pos .. " taking " .. bol_tol_rol, sort = suffix_type})
			end
		end
		labels[pos .. " taking " .. suffix_type .. " suffixes"] = {
			description = ("{{{langname}}} %s taking [[%s]] suffixes, %s"):format(pos, suffix_type, desc),
			additional = ("See also the [[Appendix:Hungarian_suffixes#By_reference_to_position_or_direction|list of %s suffixes]]."):format(suffix_type),
			breadcrumb = pos == "terms" and suffix_type .. " suffixes" or pos,
			parents = parents,
		}
	end
end

labels["verbs used with a form of maga"] = {
	description = "{{{langname}}} verbs used with a form of the pronoun {{m|hu|maga||you|pos=formal, singular}}.",
	displaytitle = "{{{langname}}} verbs used with a form of the pronoun {{m|hu||maga}}",
	breadcrumb = "used with {{m|hu||maga}}",
	parents = {{name = "verbs", sort = "maga"}},
}

for _, maga_form_spec in ipairs {
	{"magába", "-ba/-be"},
	{"magáért", "-ért"},
	{"magához", "-hoz/-hez/-höz"},
	{"magára", "-ra/-re"},
} do
	local maga_form, suffixes = unpack(maga_form_spec)
	labels["verbs used with " .. maga_form] = {
		description = "{{{langname}}} verbs used with {{m|hu|" .. maga_form .. "}}, a form of the pronoun {{m|hu|maga||you|pos=formal, singular}}.",
		displaytitle = "{{{langname}}} verbs used with {{m|hu||" .. maga_form .. "}}",
		breadcrumb = "{{m|hu||" .. maga_form .. "}}",
		parents = {
			{name = "verbs used with a form of maga", sort = suffixes},
			{name = "verbs taking " .. suffixes, sort = "maga"},
		},
	}
end

labels["verbs used reflexively with magát"] = {
	description = "{{{langname}}} verbs used reflexively with {{m|hu|magát}}, a form of the pronoun {{m|hu|maga||you|pos=formal, singular}}.",
	displaytitle = "{{{langname}}} verbs used reflexively with {{m|hu||magát}}",
	breadcrumb = "used with {{m|hu||magát}}",
	parents = {
		{name = "reflexive verbs", sort = "magát"},
		{name = "verbs used with a form of maga", sort = "t"},
	},
}

table.insert(handlers, function(data)
	local plpos, suffixes_arg = data.label:match("^([a-z]+s) taking (.-)$")
	if plpos and (plpos == "terms" or poses_taking_arguments[plpos]) then
		local suffixes = split(suffixes_arg, "/")
		local suftype
		if suffixes[1]:sub(1, 1) == "-" then
			if suffixes[2] then
				suftype = "suffix variants"
			else
				suftype = "suffix"
			end
		else
			suftype = "postposition"
		end
		local linked_suffixes = {}
		local tagged_suffixes = {}
		for i, suffix in ipairs(suffixes) do
			linked_suffixes[i] = "{{m|hu|" .. suffix .. "}}"
			tagged_suffixes[i] = "{{m|hu||" .. suffix .. "}}"
		end
		linked_suffixes = m_table.serialCommaJoin(linked_suffixes, {conj = "or"})
		tagged_suffixes = table.concat(tagged_suffixes, "/")

		local desc = ("{{{langname}}} %s that can govern the %s %s."):format(plpos, suftype, linked_suffixes)
		local displaytitle = ("{{{langname}}} %s taking %s"):format(plpos, tagged_suffixes)
		if plpos == "terms" then
			return {
				description = desc,
				displaytitle = displaytitle,
				breadcrumb_and_first_sort_base = tagged_suffixes,
				parents = {"terms taking arguments"},
			}
		else
			return {
				description = desc,
				preceding = plpos == "verbs" and "{{hu-argument-verb}}" or nil,
				displaytitle = displaytitle,
				breadcrumb_and_first_sort_base = plpos,
				parents = {"terms taking " .. suffixes_arg, {name = plpos .. " by argument", sort = {sort_base = suffixes_arg}}},
			}
		end
	end
end)

return { LABELS = labels, HANDLERS = handlers }