Module:category tree/poscatboiler/data/lang-specific/hsb

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

This module handles generating the descriptions and categorization for Upper Sorbian category pages of the format "Upper Sorbian LABEL" where LABEL can be any text. Examples are Category:Bulgarian conjugation 2.1 verbs and Category:Russian velar-stem neuter-form nouns. This module is part of the poscatboiler system, which is a general framework for generating the descriptions and categorization of category pages.

For more information, see Module:category tree/poscatboiler/data/lang-specific/documentation.

NOTE: If you add a new language-specific module, you must add the language code to the list at the top of Module:category tree/poscatboiler/data/lang-specific in order for the module to be recognized.


local labels = {}
local handlers = {}

local rfind = mw.ustring.find
local rmatch = mw.ustring.match


--------------------------------- Adjectives --------------------------------

local adj_like_poses = {"adjective", "pronoun", "determiner", "numeral", "suffix"}
for _, pos in ipairs(adj_like_poses) do
	local plpos = require("Module:string utilities").pluralize(pos)
	labels["hard " .. plpos] = {
		description = "{{{langname}}} hard-stem " .. plpos .. ".",
		breadcrumb = "hard",
		parents = {{name = plpos .. " by inflection type", sort = "hard-stem"}},
	}
	labels["soft " .. plpos] = {
		description = "{{{langname}}} soft-stem " .. plpos .. ".",
		breadcrumb = "soft",
		parents = {{name = plpos .. " by inflection type", sort = "soft-stem"}},
	}
	labels[plpos .. " with short forms"] = {
		description = "{{{langname}}} " .. plpos .. " with short-form inflections.",
		breadcrumb = "with short forms",
		parents = {{name = plpos .. " by inflection type", sort = "short forms"}},
	}
end


--------------------------------- Nouns/Pronouns/Numerals --------------------------------

local possible_animacies = {"personal", "animal", "inanimate"}
local possible_genders = {"masculine", "feminine", "neuter"}

for _, pos in ipairs({"nouns", "pronouns", "numerals"}) do
	local sgpos = pos:gsub("s$", "")
	
	local function make_label(label, description, props)
		local full_label
		if rfind(label, "POS") then
			full_label = label:gsub("POS", pos)
		else
			full_label = pos .. " " .. label
		end
		local full_description
		if rfind(description, "POS") then
			full_description = description:gsub("POS", pos)
		else
			full_description = pos .. " " .. description
		end
		full_description = "{{{langname}}} " .. full_description
		props.description = full_description
		if not props.breadcrumb then
			props.breadcrumb = label:gsub(" *POS *", " ")
			props.breadcrumb = mw.text.trim(props.breadcrumb)
		end
		labels[full_label] = props
	end

	make_label("adjectival POS",
		"with adjectival endings.",
		{parents = {pos}}
	)

	make_label("by stem type and gender",
		"categorized by stem type and gender.",
		{parents = {name = pos .. " by inflection type", sort = "stem type and gender"}}
	)

	make_label("that change gender in the plural",
		"with a different gender in the singular vs. the plural, as determined by adjective concord.",
		{
			breadcrumb = "changing gender in the plural",
			parents = {
				{name = pos .. " by stem type and gender", sort = "changing gender in the plural"},
				{name = "irregular " .. pos, sort = "changing gender in the plural"},
			},
		}
	)

	for _, gender in ipairs(possible_genders) do
		make_label(gender .. " POS by stem type",
			("%s POS categorized by stem type."):format(gender),
			{
				breadcrumb = gender,
				parents = {pos .. " by stem type and gender"},
			}
		)
		make_label(gender .. " adjectival POS",
			("%s adjectival POS."):format(gender),
			{
				breadcrumb = gender,
				parents = {"adjectival " .. pos},
			}
		)
		make_label("indeclinable " .. gender .. " POS",
			("indeclinable %s POS. Currently only POS with multiple declensions including at least one that is "
				.. "declinable are included."):format(gender),
			{
				breadcrumb = gender,
				parents = {"indeclinable " .. pos},
			}
		)
		make_label("mostly indeclinable " .. gender .. " POS",
			("mostly indeclinable %s POS, i.e. indeclinable in all but a few case/number combinations."
				):format(gender),
			{
				breadcrumb = "mostly indeclinable",
				parents = {"indeclinable " .. gender .. " " .. pos},
			}
		)
	end

	make_label("with quantitative vowel alternation",
		"with stem alternation between a long vowel (''á'', ''é'', ''í'', ''ou'' or ''ů'') and the corresponding " ..
		"short vowel (''a'', ''e'', ''i'', ''o'' or ''u''), depending on the form.",
		{
			additional = ("See also [[:Category:{{{langname}}} %s with í-ě alternation]]."):format(pos),
			parents = {name = pos, sort = "quantitative vowel alternation"},
		}
	)

	make_label("with reducible stem",
		"with a reducible stem, where an extra vowel is inserted " ..
			"before the last stem consonant in the nominative singular and/or genitive plural.",
		{parents = {name = pos .. " by inflection type", sort = "reducible stem"}}
	)

	make_label("with multiple stems",
		"with multiple stems.",
		{parents = {name = pos .. " by inflection type", sort = "multiple stems"}}
	)

	make_label("masculine personal POS",
		"masculine personal POS, i.e. POS referring (mostly) to male beings.",
		{
			breadcrumb = "personal",
			parents = {{name = "masculine " .. pos, sort = "personal"}},
		}
	)

	make_label("masculine animal POS",
		"masculine animal POS, i.e. POS referring (mostly) to animals.",
		{
			breadcrumb = "animal",
			parents = {{name = "masculine " .. pos, sort = "animal"}},
		}
	)

	make_label("masculine inanimate POS",
		"masculine inanimate POS, i.e. POS referring to inanimate objects that have masculine agreement patterns.",
		{
			breadcrumb = "inanimate",
			parents = {{name = "masculine " .. pos, sort = "inanimate"}},
		}
	)

	make_label("with regular foreign declension",
		"with a foreign ending such as ''-us'', ''-os'', ''-es'', ''-um'', ''-on'' or silent ''-e'', which is dropped in " ..
		"all cases except the nominative singular and maybe the accusative singular and vocative singular.",
		{parents = {name = pos .. " by inflection type", sort = "regular foreign declension"}}
	)

	make_label("with irregular stem",
		"with an irregular stem, which occurs in all cases except the nominative singular and maybe the accusative "
		.. "singular and vocative singular.",
		{parents = {name = "irregular " .. pos, sort = "stem"}}
	)
end

local noun_stem_gender_endings = {
    masculine = {
		["hard stem"]         = {"a paired hard or unpaired consonant", "''-a'' or ''-u'' if inanimate, ''-a'' otherwise", "''-ojo'' if personal, ''-y'' otherwise"},
		["soft stem"]         = {"a paired soft or unpaired consonant", "''-a'' or ''-u'' if inanimate, ''-a'' otherwise", "''-ojo'' if personal, ''-e'' otherwise"},
		["velar stem"]        = {"a velar", "''-a'' or ''-u'' if inanimate, ''-a'' otherwise", "''-ojo'' if personal, ''-i'' otherwise"},
	},
    feminine = {
		["hard stem"]         = {"a hard consonant + ''-a''", "''-y''", "''-y''"},
		["soft stem"]         = {"a soft consonant optionally + ''-a''", "''-e''", "''-e''"},
		["velar stem"]        = {"a velar + ''-a''", "''-i''", "''-i''"},
		["v-stem"]            = {"''-ej''", "''-wje''", "''-wje''"},
	},
    neuter = {
		["hard stem"]         = {"a hard consonant + ''-o''", "''-a''", "''-a''"},
		["soft stem"]         = {"a soft consonant + ''-e'' or sometimes ''-o''", "''-a''", "''-a''"},
		["velar stem"]        = {"a velar + ''-o''", "''-a''", "''-a''"},
		["n-stem"]            = {"''-o''", "''-enja''", "''-enja''"},
		["t-stem"]            = {"''-o''", "''-eća''", "''-ata''"},
	},
}

table.insert(handlers, function(data)
	for _, gender in ipairs(possible_genders) do
		-- check for e.g. '{{{langname}}} masculine hard-stem nouns' or '{{{langname}}} neuter n-stem nouns'
		local stemtype, pos = rmatch(data.label, "^" .. gender .. " (.+) ([^ ]+)s$")
		local breadcrumb = stemtype
		if stemtype then
			if noun_stem_gender_endings[gender] then
				local endings = noun_stem_gender_endings[gender][stemtype]
				if endings then
					local nom_s, gen_s, nom_p = unpack(endings)
					local additional =
						("This type normally ends in %s in the nominative singular; %s in the genitive singular; and %s in the nominative plural."):
						format(nom_s, gen_s, nom_p)
					return {
						description = "{{{langname}}} " .. data.label .. ".",
						additional = additional,
						breadcrumb = breadcrumb,
						parents = {
							{name = gender .. " " .. pos .. "s by stem type", sort = stemtype:gsub("%-", "")}
						},
					}
				end
			end
		end
	end
end)

return {LABELS = labels, HANDLERS = handlers}