模組:Category tree/poscatboiler/data/lang-specific/uk


This module handles generating the descriptions and categorization for 烏克蘭語 category pages of the format "烏克蘭語 LABEL" where LABEL can be any text. Examples are Category:Bulgarian conjugation 2.1 verbs and Category:Russian velar-stem neuter-form nouns. 該模块是 poscatboiler 系統的一部分,該系統是用於生成分類頁面的描述和分類的通用框架。

有關更多資訊,請參閱Module:category tree/poscatboiler/data/lang-specific/doc

注意:如果您新增了特定語言的模块,請將語言代碼新增至 Module:category tree/poscatboiler/data/lang-specific 頂部的清單中,使程式碼能識別該模块。


local labels = {}
local handlers = {}

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

-- version of rsubn() that discards all but the first return value
local function rsub(term, foo, bar)
	local retval = rsubn(term, foo, bar)
	return retval
end


--------------------------------- Verbs --------------------------------

labels["依類別分類的動詞"] = {
	description = "本分類收錄依類別分類的烏克蘭語動詞。",
	parents = {{name = "依屈折分類的動詞", sort = "類別"}},
}

labels["依類別和重音模式分類的動詞"] = {
	description = "本分類收錄依類別和重音模式分類的烏克蘭語動詞。",
	parents = {{name = "依屈折分類的動詞", sort = "類別和重音模式"}},
}

table.insert(handlers, function(data)
	local cls, variant, pattern = rmatch(data.label, "^([0-9]*)([()%[%]°]*)([abc]?)類動詞$")
	if cls then
		if pattern == "" then
			return {
				description = "烏克蘭語" .. cls .. "類動詞。",
				breadcrumb = cls,
				parents = {{name = "依類別分類的動詞", sort = cls .. variant}},
			}
		else
			return {
				description = "烏克蘭語" .. cls .. "類動詞," ..
					"且重音模式為" .. pattern .. (
					variant == "" and "" or ",變體" .. variant) .. "。" .. (
					pattern == "a" and "這種模式所有變形的重音都在詞幹。"
					or pattern == "b" and "這種模式所有變形的重音都在詞尾。"
					or "這種模式第一人稱單數現在時直陳式和除現在時直陳式之外的所有形式 " ..
					"的重音都在詞尾,除第一人稱單數之外的現在時直陳式變形的重音都在詞幹。").. (
					variant == "" and "" or
					cls == "3" and variant == "°" and "變體符號表示詞幹的-н在大多數非現在時形式中消失。" or
					cls == "3" and (variant == "(°)" or variant == "[°]") and
					"變體符號表示詞幹的-н在大多數非現在時形式中可消失可不消失。" or
					cls == "6" and variant == "°" and
					"變體符號表示現在時不是" ..
					"[[Appendix:術語表#iota化|iota化的]]。(在大多數這類動詞中," ..
					"現在時是iota化的,例如писа́ти的現在時" ..
					"пишу́、пи́шеш、пи́ше等)"
				),
				breadcrumb = cls .. variant .. pattern,
				parents = {
					{name = cls .. "類動詞", sort = pattern},
					{name = "依類別和重音模式分類的動詞", sort = cls .. pattern},
				},
			}
		end
	end
end)


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

labels["adjectives by stem type and stress"] = {
	description = "Ukrainian adjectives categorized by stem type and stress. " ..
		"Unlike for nouns, adjectives are consistently either stem-stressed or ending-stressed.",
	parents = {{name = "adjectives by inflection type", sort = "stem type and stress"}},
}


local adj_stem_expl = {
	["ц-詞幹"] = "-ц",
	["元音詞幹"] = "a vowel, or -й or -ь",
	["軟音詞幹"] = "a soft consonant",
	["硬音詞幹"] = "a hard consonant",
	["possessive"] = "-ов, -єв, -ин or -їн",
}

local adj_decl_endings = {
	["hard stem-stressed"] = {"-ий", "-а", "-е", "-і"},
	["hard ending-stressed"] = {"-и́й", "-а́", "-е́", "-і́"},
	["soft"] = {"-ій", "-я", "-є", "-і"},
	["c-詞幹"] = {"-ий", "-я", "-е", "-і"},
	["j-詞幹"] = {"-їй", "-я", "-є", "-ї"},
	["possessive"] = {"-", "-а", "-е", "-і"},
	["surname"] = {"-", "-а", "(nil)", "-и"},
}

table.insert(handlers, function(data)
	-- FIXME! Harmonize stem types here with stem types in 'adj_decl_endings' (used
	-- directly in adjectival nouns).
	local function stem_to_ending_type(stem, stress)
		if stem == "硬音詞幹" and stress == "stem" then
			return "hard stem-stressed"
		elseif stem == "硬音詞幹" and stress == "ending" then
			return "hard ending-stressed"
		elseif stress == "" then
			if stem == "軟音詞幹" then
				return "軟音"
			elseif stem == "ц-詞幹" then
				return "c-詞幹"
			elseif stem == "元音詞幹" then
				return "j-詞幹"
			elseif stem == "possessive" then
				return "possessive"
			end
		end
		return nil
	end

	local breadcrumb, stem, stress = rmatch(data.label, "^(([^ ]*) ([^ *]*)-stressed) adjectives")
	if not breadcrumb then
		breadcrumb, stem = rmatch(data.label, "^(([^ ]*)) adjectives")
		stress = ""
	end
	if breadcrumb then
		local ending_type = stem_to_ending_type(stem, stress)
		if ending_type and adj_stem_expl[stem] then
			local m, f, n, p = unpack(adj_decl_endings[ending_type])
			local stresstext = stress == "stem" and
				"The adjectives in this category have stress on the stem." or
				stress == "ending" and
				"The adjectives in this category have stress on the endings." or
				"All adjectives of this type have stress on the stem."
			local endingtext = "ending in the nominative in masculine singular " .. m ..
				", feminine singular " .. f .. ", neuter singular " .. p .. " and plural " ..
				p .. "."
			local stemtext = " The stem ends in " .. adj_stem_expl[stem] .. "."
			return {
				description = "Ukrainian " .. stem .. " adjectives, " .. endingtext .. stemtext .. " " .. stresstext,
				breadcrumb = breadcrumb,
				parents = {"adjectives by stem type and stress"},
			}
		end
	end
end)


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

for _, pos in ipairs({"nouns", "pronouns", "numerals"}) do
	local sgpos = pos:gsub("s$", "")
	labels[pos .. " by stem type and gender"] = {
		description = "Ukrainian " .. pos .. " categorized by stem type and typical gender. " ..
			"Note that \"typical gender\" means the gender that is typical for the " .. sgpos .. "'s ending (e.g. most " .. pos .. " in ''-а'' are " ..
			"feminine, and hence all such " .. pos .. " are considered to be \"typically feminine\"; but some are in fact masculine).",
		parents = {{name = pos .. " by inflection type", sort = "stem type and gender"}},
	}

	labels[pos .. " by stem type, gender and accent pattern"] = {
		description = "Ukrainian " .. pos .. " categorized by stem type, typical gender and " ..
			"accent pattern. Note that \"typical gender\" means the gender that is typical for the " .. sgpos .. "'s ending (e.g. most " ..
			pos .. " in ''-а'' are feminine, and hence all such " .. pos .. " are considered to be \"typically feminine\"; but some are in " ..
			"fact masculine). See [[Template:uk-ndecl]] for further information on accent patterns.",
		parents = {{name = pos .. " by inflection type", sort = "stem type, gender and accent pattern"}},
	}

	labels[pos .. " by vowel alternation"] = {
		description = "Ukrainian " .. pos .. " categorized according to their vowel alternation pattern (e.g. ''і'' vs. ''о'').",
		parents = {{name = pos, sort = "vowel alternation"}},
	}

	labels[pos .. " by accent pattern"] = {
		description = "Ukrainian " .. pos .. " categorized according to their accent pattern (see [[Template:uk-ndecl]]).",
		parents = {{name = pos .. " by inflection type", sort = "accent pattern"}},
	}

	labels[pos .. " with reducible stem"] = {
		description = "Ukrainian " .. pos .. " 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"}},
	}

	labels[pos .. " with multiple stems"] = {
		description = "Ukrainian " .. pos .. " with multiple stems.",
		parents = {{name = pos .. " by inflection type", sort = "multiple stems"}},
	}

	labels[pos .. " with multiple accent patterns"] = {
		description = "Ukrainian " .. pos .. " with multiple accent patterns. See [[Template:uk-ndecl]].",
		parents = {{name = pos .. " by inflection type", sort = "multiple accent patterns"}},
	}

	labels["adjectival " .. pos] = {
		description = "Ukrainian " .. pos .. " with adjectival endings.",
		parents = {pos},
	}

	labels[pos .. " with irregular stem"] = {
		description = "Ukrainian " .. pos .. " with an irregular stem, which occurs in all cases except the nominative singular and maybe the accusative singular.",
		parents = {{name = "irregular " .. pos, sort = "stem"}},
	}

	labels[pos .. " with irregular plural stem"] = {
		description = "Ukrainian " .. pos .. " with an irregular plural stem, which occurs in all cases.",
		parents = {{name = "irregular " .. pos, sort = "plural stem"}},
	}
end

local noun_stem_expl = {
	["hard"] = "a hard consonant",
	["velar-stem"] = "a velar (-к, -г or –x)",
	["semisoft"] = "a hushing consonant (-ш, -ж, -ч or -щ)",
	["soft"] = "a soft consonant",
	["c-stem"] = "-ц",
	["j-stem"] = "conceptual -й",
	["n-stem"] = "-м' (with -ен- in some forms)",
	["t-stem"] = "-я or -а (with -т- in most forms)",
	["possessive"] = "-ов, -єв, -ин or -їн",
	["surname"] = "-ов, -ів, -їв, -єв, -ин, -ін or -їн",
}

local noun_stem_to_declension = {
	["third-declension"] = "third",
	["fourth-declension"] = "fourth",
	["t-stem"] = "fourth",
	["n-stem"] = "fourth",
}

local noun_stem_gender_endings = {
    masculine = {
		["hard"]              = {"a hard consonant", "-и"},
		["velar-stem"]        = {"a velar", "-и"},
		["semisoft"]          = {"a hushing consonant or -р", "-і"},
		["soft"]              = {"-ь or -р", "-і"},
		["j-stem"]            = {"-й", "-ї"},
	},
    feminine = {
		["hard"]              = {"-а", "-и"},
		["semisoft"]          = {"-а", "-і"},
		["soft"]              = {"-я", "-і"},
		["j-stem"]            = {"-я", "-ї"},
		["third-declension"]  = {"-ь, -р, a labial, or a hushing consonant", "-і"},
	},
    neuter = {
		["hard"]              = {"-о", "-а"},
		["velar-stem"]        = {"-о", "-а"},
		["semisoft"]          = {"-е", "-а"},
		["soft"]              = {"-е", "-я"},
		["j-stem"]            = {"-є", "-я"},
		["fourth-declension"] = {"-я", "-я"},
		["t-stem"]            = {"-я or -а", "-та"},
		["n-stem"]            = {"-я", "-я"},
	},
}

table.insert(handlers, function(data)
	local function escape_accent(accent)
		return rsub(accent, "'", "'")
	end

	local function get_stem_gender_text(stem, genderspec, pos)
		local gender = genderspec
		gender = rsub(gender, " in %-[ое]$", "")
		if not noun_stem_gender_endings[gender] then
			return nil
		end
		local endings = noun_stem_gender_endings[gender][stem]
		if not endings then
			return nil
		end
		local sgending, plending = endings[1], endings[2]
		local stemtext = noun_stem_expl[stem] and " The stem ends in " .. noun_stem_expl[stem] .. "." or ""
		local decltext =
			rfind(stem, "declension") and "" or
			" This is traditionally considered to belong to the " .. (
				noun_stem_to_declension[stem] or gender == "feminine" and "first" or "second"
			) .. " declension."
		local genderdesc
		if rfind(genderspec, "in %-[ое]$") then
			genderdesc = rsub(genderspec, "in (%-[ое])$", pos .. "s ending in %1")
		else
			genderdesc = "usually " .. gender .. " " .. pos .. "s"
		end
		return stem .. ", " .. genderdesc .. ", normally ending in " .. sgending .. " in the nominative singular " ..
			" and " .. plending .. " in the nominative plural." .. stemtext .. decltext
	end

	local stem, gender, accent, pos = rmatch(data.label, "^(.*) (.-) adjectival accent%-(.-) (.*)s$")
	if not stem then
		stem, gender, pos = rmatch(data.label, "^(.*) (.-) adjectival (.*)s$")
	end
	if stem and noun_stem_expl[stem] then
		local stemspec
		if stem == "hard" then
			stemspec = accent == "a" and "hard stem-stressed" or "hard ending-stressed"
		else
			stemspec = stem
		end
		local endings = adj_decl_endings[stemspec]
		if endings then
			local stemtext = " The stem ends in " .. noun_stem_expl[stem] .. "."
			local accentdesc = accent == "a" and
				"This " .. pos .. " is stressed according to accent pattern a (stress on the stem)." or
				accent == "b" and
				"This " .. pos .. " is stressed according to accent pattern b (stress on the ending)." or
				"All " .. pos .. "s of this class are stressed according to accent pattern a (stress on the stem)."
			local accenttext = accent and " accent-" .. accent or ""
			local m, f, n, pl = unpack(endings)
			local sg =
				gender == "masculine" and m or
				gender == "feminine" and f or
				gender == "neuter" and n or
				nil
			return {
				description = "Ukrainian " .. stem .. " " .. gender .. " " .. pos ..
				"s, with adjectival endings, ending in " .. (sg and sg .. " in the nominative singular and " or "") ..
				pl .. " in the nominative plural." .. stemtext .. " " .. accentdesc,
				breadcrumb = stem .. " " .. gender .. accenttext,
				parents = {
					{name = "adjectival " .. pos .. "s", sort = stem .. " " .. gender .. accenttext},
					pos .. "s by stem type, gender and accent pattern",
				}
			}
		end
	end

	local part1, stem, gender, accent, part2, pos = rmatch(data.label, "^((.-) (.-)%-form) accent%-(.-)( (.*)s)$")
	local ending
	if not stem then
		-- check for e.g. 'Ukrainian hard masculine accent-a nouns in -о'
		part1, stem, gender, accent, part2, pos, ending = rmatch(data.label, "^((.-) ([a-z]+ine)) accent%-(.-)( (.*)s in %-([ое]))$")
		if stem then
			gender = gender .. " in -" .. ending
		end
	end
	if stem then
		local stem_gender_text = get_stem_gender_text(stem, gender, pos)
		if stem_gender_text then
			local accent_text = " This " .. pos .. " is stressed according to accent pattern " ..
				escape_accent(accent) .. " (see [[Template:uk-ndecl]])."
			return {
				description = "Ukrainian " .. stem_gender_text .. accent_text,
				breadcrumb = "Accent-" .. escape_accent(accent),
				parents = {
					{name = part1 .. part2, sort = accent},
					pos .. "s by stem type, gender and accent pattern",
				}
			}
		end
	end

	local stem, gender, pos = rmatch(data.label, "^(.-) (.-)%-form (.*)s$")
	if not stem then
		-- check for e.g. 'Ukrainian hard masculine nouns in -о'
		stem, gender, pos, ending = rmatch(data.label, "^(.-) ([a-z]+ine) (.*)s in %-([ое])$")
		if stem then
			gender = gender .. " in -" .. ending
		end
	end
	if stem then
		local stem_gender_text = get_stem_gender_text(stem, gender, pos)
		if stem_gender_text then
			return {
				description = "Ukrainian " .. stem_gender_text,
				breadcrumb = ending and stem .. " " .. gender or stem .. " " .. gender .. "-form",
				parents = {pos .. "s by stem type and gender"},
			}
		end
	end

	local pos, accent = rmatch(data.label, "^(.*)s with accent pattern (.*)$")
	if accent then
		return {
			description = "Ukrainian " .. pos .. "s with accent pattern " .. escape_accent(accent) ..
				" (see [[Template:uk-ndecl]]).",
			breadcrumb = {name = escape_accent(accent), nocap = true},
			parents = {{name = pos .. "s by accent pattern", sort = accent}},
		}
	end

	local pos, fromto, altfrom, altto = rmatch(data.label, "^(.*)s with ((.*)%-(.*)) alternation$")
	if altfrom then
		return {
			description = "Ukrainian " .. pos .. "s with vowel alternation between " .. altfrom ..
				" in the lemma and " .. altto .. " in the last syllable of some or all remaining forms.",
			breadcrumb = {name = fromto, nocap = true},
			parents = {{name = pos .. "s by vowel alternation", sort = fromto}},
		}
	end
end)


return {LABELS = labels, HANDLERS = handlers}