Module:Category tree/poscatboiler/data/lang-specific/he

From The Languages of David J. Peterson
Jump to navigation Jump to search

Documentation for this module may be created at Module:Category tree/poscatboiler/data/lang-specific/he/documentation

local labels = {}
local handlers = {}

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

local m_table = require("Module:table")


-- FIXME: It should be possible to compute the plene form automatically.
local plene_form_for_pattern = {
	["קְטֵלָה"] = "קטילה",
	["קְטֻלָּה"] = "קטולה",
	["קֹטֶל"] = "קוטל",
	["קִטָּלוֹן"] = "קיטלון",
	["מְקֻטָּל"] = "מקוטל",
}


labels["terms by pattern"] = {
	description = "Hebrew terms classified by their pattern. A ''pattern'' in the Semitic languages is a phonological template " ..
	"with specified vowels, into which the consonants of the root are inserted. By convention, the verb " ..
	"{{m|he|קָטַל|tr=katál||to kill}} is used to fill out the consonants of the pattern.",
	parents = {"lemmas"},
}

table.insert(handlers, function(data)
	local pattern = mw.ustring.match(data.label, "^terms in the pattern ([" .. mw.ustring.char(0x0590) .. "-" .. mw.ustring.char(0x05FF) .. "]+)$")
	if pattern then
		local plene = plene_form_for_pattern[pattern]
		local link = require("Module:links").full_link({ lang = lang, term = pattern }, "term")
		local altlink = require("Module:links").full_link({ lang = lang, alt = pattern }, "term")
		return {
			description = "Hebrew terms that are in the pattern, or ''mishkál'', <big>{{he-l|:Appendix:Hebrew patterns/" ..
			pattern .. "|wv=" .. (plene or pattern) .. (plene and "|dwv=" .. pattern or "") .. "}}</big>.",
			displaytitle = "Hebrew terms in the pattern " .. altlink,
			breadcrumb = altlink,
			parents = {{name = "terms by pattern", sort = pattern}},
		}
	end
end)


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

labels["verbs with weak roots"] = {
	description = "{{{langname}}} verbs with weak roots.",
	breadcrumb = "with weak roots",
	parents = {{name = "verbs", sort = "weak roots"}},
}

local binyans = {
	["pa'al"] = 1,
	["nif'al"] = 2,
	["pi'el"] = 3,
	["pu'al"] = 4,
	["hif'il"] = 5,
	["huf'al"] = 6,
	["hitpa'el"] = 7,
	["hitpu'al"] = 8, -- a suspect binyan
}
local radical_identifier = {
	["פ"] = "first",
	["ע"] = "second",
	["ל"] = "third",
}
local weak_letter = m_table.listToSet { "א", "ה", "ו", "ח", "י", "נ", "ע", "ר" }

local function construction_cat(binyan)
	return "'''[[:Category:{{{langname}}} " .. binyan .. " verbs|{{{langname}}} verbs of the " .. binyan .. " construction]]'''"
end

for binyan, order in pairs(binyans) do
	-- Add label for e.g. [[Category:Hebrew hif'il verbs]].
	labels[binyan .. " verbs"] = {
		description = "{{{langname}}} verbs in the ''[[Appendix:Hebrew verbs#" .. binyan .. "|" .. binyan .. "]]'' [[binyan]].",
		breadcrumb = "''" .. binyan .. "''",
		parents = {{name = "verbs", sort = " " .. order}},
	}
	-- Add label for e.g. [[Category:Hebrew hif'il verbs with weak roots]].
	labels[binyan .. " verbs with weak roots"] = {
		description = construction_cat(binyan) .. " with weak roots.",
		breadcrumb = "with weak roots",
		parents = {
			{name = binyan .. " verbs", sort = "*"},
			{name = "verbs with weak roots", sort = " " .. order},
		}
	}
end

-- Handler for e.g. [[Category:Hebrew ל״ה verbs]] and [[Category:Hebrew ל״ה hif'il verbs]].
table.insert(handlers, function(data)
	local radical_and_letter, radical, letter, binyan = mw.ustring.match(data.label, "^((.)״(.)) ([^ ]*) verbs$")
	if not radical then
		radical_and_letter, radical, letter = mw.ustring.match(data.label, "^((.)״(.)) verbs$")
	end
	if radical and radical_identifier[radical] and weak_letter[letter] and (not binyan or binyans[binyan]) then
		local altlink = "{{m|he||" .. radical_and_letter .. "}}"
		if radical == "ע" and letter == "ע" then -- double-ayin verbs
			desc = "with geminate roots"
		else
			desc = "with weak roots having " .. letter .. " as their " .. radical_identifier[radical] .. " radical"
		end
		if binyan then
			return {
				description = construction_cat(binyan) .. " " .. desc .. ".",
				displaytitle = "{{{langname}}} " .. altlink .. " " .. binyan .. " verbs",
				breadcrumb = "''" .. binyan .. "''",
				parents = {
					{name = radical_and_letter .. " verbs", sort = " " .. binyans[binyan]},
					{name = binyan .. " verbs with weak roots", sort = radical .. letter}
				},
			}
		else
			return {
				description = "{{{langname}}} verbs " .. desc .. ".",
				displaytitle = "{{{langname}}} " .. altlink .. " verbs",
				breadcrumb = altlink,
				parents = {{name = "verbs with weak roots", sort = radical .. letter}},
			}
		end
	end

	local binyan = mw.ustring.match(data.label, "^([^ ]*) verbs$")
	if binyan and binyans[binyan] then
	end
end)

return {LABELS = labels, HANDLERS = handlers}