This data submodule defines part of Wiktionary's category structure.

For an introduction to the poscatboiler system and a description of how to add or modify categories, see Module:category tree/poscatboiler/data/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["ศัพท์แบ่งตามแบบรูป"] = {
	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 = {"คำหลัก"},
}

table.insert(handlers, function(data)
	local pattern = mw.ustring.match(data.label, "^ศัพท์ที่อยู่ในแบบรูป ([" .. 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|:ภาคผนวก:แบบรูปภาษาฮีบรู/" ..
			pattern .. "|wv=" .. (plene or pattern) .. (plene and "|dwv=" .. pattern or "") .. "}}</big>.",
			displaytitle = "ศัพท์ภาษาฮีบรูที่อยู่ในแบบรูป " .. altlink,
			breadcrumb = altlink,
			parents = {{name = "ศัพท์แบ่งตามแบบรูป", sort = pattern}},
		}
	end
end)


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

labels["คำกริยาที่มี weak roots"] = {
	description = "{{{langname}}} verbs with weak roots.",
	breadcrumb = "with weak roots",
	parents = {{name = "คำกริยา", sort = "weak roots"}},
}

local binyans = {
	["ปาอัล"] = 1,
	["นิฟอัล"] = 2,
	["ปีเอ็ล"] = 3,
	["ปูอัล"] = 4,
	["ฮิฟอิล"] = 5,
	["ฮุฟอัล"] = 6,
	["ฮิตปาเอ็ล"] = 7,
	["ฮิตปูอัล"] = 8, -- a suspect binyan
}
local radical_identifier = {
	["פ"] = "ที่หนึ่ง",
	["ע"] = "ที่สอง",
	["ל"] = "ที่สาม",
}
local weak_letter = m_table.listToSet { "א", "ה", "ו", "ח", "י", "נ", "ע", "ר" }

local function construction_cat(binyan)
	return "'''[[:หมวดหมู่:คำกริยา" .. binyan .. "{{{langcat}}}|คำกริยา{{{langcat}}}ของการสร้าง''" .. binyan .. "'']]'''"
end

for binyan, order in pairs(binyans) do
	-- Add label for e.g. [[Category:Hebrew hif'il verbs]].
	labels["คำกริยา" .. binyan] = {
		description = "คำกริยา{{{langcat}}}ใน[[บินยัน]] ''[[ภาคผนวก:คำกริยาภาษาฮีบรู#" .. binyan .. "|" .. binyan .. "]]''",
		breadcrumb = "''" .. binyan .. "''",
		parents = {{name = "คำกริยา", sort = " " .. order}},
	}
	-- Add label for e.g. [[Category:Hebrew hif'il verbs with weak roots]].
	labels["คำกริยา" .. binyan .. "ที่มี weak roots"] = {
		description = construction_cat(binyan) .. " ที่มี weak roots.",
		breadcrumb = "ที่มี weak roots",
		parents = {
			{name = "คำกริยา" .. binyan, sort = "*"},
			{name = "คำกริยาที่มี weak roots", sort = " " .. order},
		}
	}
end

-- Handler for e.g. [[Category:Hebrew ל״ה verbs]] and [[Category:Hebrew ל״ה hif'il verbs]].
table.insert(handlers, function(data)
	local binyan, radical_and_letter, radical, letter = mw.ustring.match(data.label, "^คำกริยา([ปาอัลนิฟีเฮู็ตุ]+) ((.)״(.))$")
	if not radical then
		radical_and_letter, radical, letter = mw.ustring.match(data.label, "^คำกริยา ((.)״(.))$")
	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 = "ที่มี geminate roots"
		else
			desc = "ที่มี weak roots having " .. letter .. " as their " .. radical_identifier[radical] .. " radical"
		end
		if binyan then
			return {
				description = construction_cat(binyan) .. " " .. desc,
				displaytitle = "คำกริยา" .. binyan .. " " .. altlink .. " {{{langcat}}}",
				breadcrumb = "''" .. binyan .. "''",
				parents = {
					{name = "คำกริยา " .. radical_and_letter, sort = " " .. binyans[binyan]},
					{name = "คำกริยา" .. binyan .. "ที่มี weak roots", sort = radical .. letter}
				},
			}
		else
			return {
				description = "คำกริยา{{{langcat}}} " .. desc,
				displaytitle = "คำกริยา" .. altlink .. " {{{langcat}}}",
				breadcrumb = altlink,
				parents = {{name = "คำกริยาที่มี weak roots", sort = radical .. letter}},
			}
		end
	end

	local binyan = mw.ustring.match(data.label, "^คำกริยา([ปาอัลนิฟีเฮู็ตุ]+)$")
	if binyan and binyans[binyan] then
	end
end)

return {LABELS = labels, HANDLERS = handlers}