Module:User:Benwing2/category tree/poscatboiler/data/lang-specific/ar

local labels = {} local handlers = {}

local m_table = require("Module:table")

- --                                                                        -- --                           NOUNS AND ADJECTIVES                          -- --                                                                        -- -

- Noun labels

labels["nouns by derivation type"] = { description = " nouns categorized by type of derivation.", parents = , breadcrumb = "by derivation type", }

labels["instance nouns"] = { description = " instance nouns, i.e. nouns having the meaning \"an instance of doing X\" for some verb.", parents = , breadcrumb = "instance nouns", }

labels["nouns of place"] = { description = " nouns of place, i.e. nouns having the approximate meaning \"the place for doing X\" for some verb.", parents = , breadcrumb = "nouns of place", }

labels["occupational nouns"] = { description = " occupational nouns, i.e. nouns referring to people employed in doing something.", parents = , breadcrumb = "occupational nouns", }

labels["relative nouns (nisba)"] = { description = " relative (nisba) nouns, i.e. abstract nouns formed with the suffix and derived from an adjective or other noun (or occasionally other parts of speech).", parents = , breadcrumb = "relative nouns (nisba)", }

labels["tool nouns"] = { description = " tool nouns, i.e. nouns having the approximate meaning \"tool for doing X\" for some verb.", parents = , breadcrumb = "tool nouns", }

labels["feminine terms lacking feminine ending"] = { description = " feminine terms that do not end in the feminine endings &lrm;, &lrm;, &lrm;, or .", additional = "It is automatically added by Module:ar-headword to lemma entries.", parents = {"nouns", "terms by lexical property", "feminine nouns"}, }

labels["masculine terms with feminine ending"] = { description = " masculine terms ending in one of the feminine endings &lrm;, &lrm;, &lrm;, or .", additional = "It is automatically added by Module:ar-headword to lemma entries.", parents = {"nouns", "terms by lexical property", "masculine nouns"}, }

- Adjective labels

labels["adjectives by derivation type"] = { description = " adjectives categorized by type of derivation.", parents = , breadcrumb = "by derivation type", }

labels["characteristic adjectives"] = { description = " characteristic adjectives, i.e. adjectives meaning \"habitually doing X\" for some verb.", parents = , breadcrumb = "characteristic", }

labels["color/defect adjectives"] = { description = " color/defect adjectives, i.e. adjectives generally referring to colors and physical defects.", parents = , breadcrumb = "color/defect", }

labels["relative adjectives (nisba)"] = { description = " relative (nisba) adjectives, i.e. adjectives formed with the suffix and meaning \"related to X\" for some noun (or occasionally other parts of speech).", parents = , breadcrumb = "relative (nisba)", }

- Noun/adjective handlers

-- Only fire if the part of speech is one of these. local allowed_pos = m_table.listToSet {"noun", "pronoun", "numeral", "adjective"} -- Only fire if one of these words occurs. local required_words = {"triptote", "diptote", "singular", "plural", "dual", "paucal", "singulative", "collective"}

table.insert(handlers, function(data)	local pos, typ = data.label:match("^([a-z]+)s with (.+)$")	if not pos or not allowed_pos[pos] then		return nil	end	local spaced_typ = " " .. typ .. " "	local ok = false	for _, required_word in ipairs(required_words) do		if spaced_typ:find(" " .. required_word .. " ") then			ok = true			break		end	end	if not ok then		return nil	end

local parents = if typ ~= "broken plural" and typ:find("broken plural") then table.insert(parents, {name = pos .. "s with broken plural", sort = typ}) end if typ:find("irregular") then table.insert(parents, {name = "irregular " .. pos .. "s", sort = typ}) end

return { description = " " .. data.label .. ".",		breadcrumb = typ, parents = parents, } end)

- --                                                                        -- --                                   VERBS                                 -- --                                                                        -- -

- Verb labels

labels["verbs with quadriliteral roots"] = { description = " verbs built on roots consisting of four radicals (instead of the more common triliteral roots), categorized by form.", parents = , breadcrumb = "with quadriliteral roots", }

labels["verbs by conjugation"] = { description = " verbs categorized by type of weakness displayed in their conjugation (as opposed to weakness determined by form, i.e. by the presence of certain \"weak\" radicals in certain positions).", parents = , breadcrumb = "by conjugation", }

labels["verbs by type of passive"] = { description = " verbs categorized by type of passive available.", parents = , breadcrumb = "by type of passive", }

labels["verbs with full passive"] = { description = " verbs with passive forms in all persons and numbers.", parents = , breadcrumb = "full passive", }

labels["verbs with impersonal passive"] = { description = " verbs with impersonal passive forms only, i.e. only in the third-person masculine singular.", parents = , breadcrumb = "impersonal passive", }

labels["verbs with no passive"] = { description = " verbs without passive forms.", parents = , breadcrumb = "no passive", }

- Verb handlers

local weakness_desc = { ["geminate"] = "the second and third radicals are identical, which sometimes causes an intervening short vowel to drop", ["assimilated"] = "the first radical is و or ي, which disappears in some forms", ["hollow"] = "the second radical is و or ي, which is replaced with a long or short vowel in some forms", ["third-weak"] = "the third of four radicals is و or ي (normally not leading to significant irregularities)", ["final-weak"] = "the last radical is و or ي, normally leading to irregular endings", ["assimilated+final-weak"] = "the first radical is و or ي and the last radical is و or ي, normally leading to irregular endings", ["sound"] = "none of the radicals is و or ي or ء, nor are the second and third radicals identical", ["hamzated"] = "one of the radicals is ء, leading to spelling and occasionally conjugation irregularities", }

local weakness_english = { ["assimilated+final-weak"] = "both assimilated and final-weak", }

local weakness_desc_by_conjugation = { ["geminate"] = "This includes verbs where the second and third radicals are identical and the vowel between them is deleted in some parts of the conjugation. This is not the same as geminate verbs by form, which is determined purely by the second and third radicals being identical, regardless of the conjugation. (For example, form-II verbs that are geminate by form are sound by conjugation.)", ["assimilated"] = "Generally this only includes form-I verbs where the first radical is و, leading to a shortened non-past stem. This is not the same as assimilated verbs by form, which is determined purely by the first radical being و or ي, regardless of the conjugation. (All verbs that are assimilated by form but not form-I are sound by conjugation, as are form-I verbs whose first radical is ي, and a few form-I verbs whose first radical is و.)", ["hollow"] = "This includes verbs where the second radical is و or ي and appears as a vowel in most parts of the conjugation. This is not the same as hollow verbs by form, which is determined only by the second radical being و or ي, regardless of the conjugation. (For example, form-II verbs that are hollow by form are sound by conjugation.)", ["final-weak"] = "This includes verbs where the the last radical is و or ي, leading to irregular endings. This is not the same as final-weak verbs by form, which is determined only by the last radical being و or ي, regardless of the conjugation, although the two categories largely coincide.", ["assimilated+final-weak"] = "Generally this only includes form-I verbs where the first radical is و and the last radical is و or ي, leading to irregular endings and a shortened non-past stem. This is not the same as verbs that are assimilated and final-weak by form, which is determined purely by both the first and last radical being و or ي, regardless of the conjugation. (All verbs that are assimilated+final-weak by form but not form-I are just final-weak by conjugation, as are form-I verbs whose first radical is ي.)", ["sound"] = "This includes regular verbs without any irregularities caused by weak (و or ي) radicals. This is not the same as sound verbs by form, which is determined purely by lacking any weak radicals, regardless of the conjugation. Some verbs with weak radicals are nonetheless sound by conjugation; an example is form-II verbs that are hollow verbs by form, i.e. with the second radical being و or ي.", }

local trilit_form_to_number = { ["I"] = 1, ["II"] = 2, ["III"] = 3, ["IV"] = 4, ["V"] = 5, ["VI"] = 6, ["VII"] = 7, ["VIII"] = 8, ["IX"] = 9, ["X"] = 10, ["XI"] = 11, ["XII"] = 12, ["XIII"] = 13, ["XIV"] = 14, ["XV"] = 15, }

local quadlit_form_to_number = { ["Iq"] = 1, ["IIq"] = 2, ["IIIq"] = 3, ["IVq"] = 4, }

local function form_to_sort_key(form, with_space) if trilit_form_to_number[form] then if with_space then return (" %02d"):format(trilit_form_to_number[form]) else return "" .. trilit_form_to_number[form] end elseif quadlit_form_to_number[form] then if with_space then return (" %02dq"):format(quadlit_form_to_number[form]) else return "" .. quadlit_form_to_number[form] end else return nil end end

local function form_link(form) return "form-" .. form .. "" end

local function weakness_link(weakness) if weakness == "hamzated" then return "hamzated" elseif weakness == "geminate" then return "geminate" elseif weakness == "sound" then return "sound" else return "" .. (weakness_english[weakness] or weakness) .. "" end end

-- Entries for e.g. Category:Arabic final-weak verbs. Use entries instead of a handler -- so that children show up in Category:Arabic verbs by inflection type. for weakness, desc in pairs(weakness_desc) do labels[weakness .. " verbs"] = { description = " verbs with " .. weakness_link(weakness) .. " roots, where " .. desc .. ".",		parents = { {name = "verbs by inflection type", sort = weakness}, },		breadcrumb = weakness, } end

-- Entries for e.g. Category:Arabic final-weak verbs by conjugation. Use entries instead of a handler -- so that children show up in [[:Category:Arabic verbs by conjugation]. for weakness, desc in pairs(weakness_desc_by_conjugation) do	labels[weakness .. " verbs by conjugation"] = {		description = " verbs conjugated as " .. weakness_link(weakness) .. ". " .. weakness_desc_by_conjugation[weakness],		parents = {			{name = "verbs by conjugation", sort = weakness},		},		breadcrumb = weakness,	} end

-- Handler for e.g. Category:Arabic form-VIII verbs. table.insert(handlers, function(data)	local form = data.label:match("^form%-([IVX]+q?) verbs$")	if not form then		return nil	end	local form_sort_key = form_to_sort_key(form, "with space")	if not form_sort_key then		return nil	end	local parents = {		{name = "verbs by inflection type", sort = form_sort_key},	}	if form:find("q$") then		table.insert(parents, {name = "verbs with quadriliteral roots", sort = form_sort_key})	end	return {		description = " " .. form_link(form) .. " verbs.",		parents = parents,		breadcrumb = "form " .. form,	} end)

-- Handler for e.g. Category:Arabic final-weak form-VIII verbs. table.insert(handlers, function(data)	local weakness, form = data.label:match("^([a-z+-]+) form%-([IVX]+q?) verbs$")	if not weakness or not weakness_desc[weakness] then		return nil	end	local form_sort_key = form_to_sort_key(form)	if not form_sort_key then		return nil	end	return {		description = " " .. form_link(form) .. " verbs with " .. weakness_link(weakness) ..		" roots, where " .. weakness_desc[weakness] .. ".",		parents = {			{name = "form-" .. form .. " verbs", sort = weakness},			{name = weakness .. " verbs", sort = form_sort_key},		},		breadcrumb = weakness,	} end)

local radical_ordinals = m_table.listToSet {"first", "second", "third", "fourth"} local weak_radicals = m_table.listToSet {"و", "ي", "ء"}

-- Handler for e.g. Category:Arabic form-IV verbs with و as second radical. table.insert(handlers, function(data)	local form, radical, ordinal = mw.ustring.match(data.label, "^form%-([IVX]+q?) verbs with (.) as ([a-z]+) radical$")	if not form then		return nil	end	local form_sort_key = form_to_sort_key(form)	if not form_sort_key then		return nil	end	if not weak_radicals[radical] or not radical_ordinals[ordinal] then		return nil	end	local weakness = radical == "ء" and "hamzated" or		ordinal == "first" and "assimilated" or		ordinal == "second" and "hollow" or		ordinal == "third" and form:match("q$") and "third-weak" or		"final-weak"	return {		description = " " .. form_link(form) .. " verbs with " .. weakness_link(weakness) ..			" roots having " .. radical .. " as their " .. ordinal .. " radical.",		parents = {			{name = weakness .. " form-" .. form .. " verbs", sort = " "},			{name = weakness .. " verbs", sort = form_sort_key .. radical},		},		breadcrumb = "form " .. form, } end)

return {LABELS = labels, HANDLERS = handlers}