Module:sem-eth-utilities

Hello, you have come here looking for the meaning of the word Module:sem-eth-utilities. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:sem-eth-utilities, but we will also tell you about its etymology, its characteristics and you will know how to say Module:sem-eth-utilities in singular and plural. Everything you need to know about the word Module:sem-eth-utilities you have here. The definition of the word Module:sem-eth-utilities will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:sem-eth-utilities, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


-- Module:gez-utilities
-- Author: Weshyaunt
-- Based on Module:sem-arb-utilities by Fenakhay, Sept 2023

local export = {}

local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local m_headword = require("Module:headword")

local m_str_utils = require("Module:string utilities")
local u = m_str_utils.char
local ulen = m_str_utils.len
local usub = m_str_utils.sub
local rmatch = m_str_utils.match
local rsplit = m_str_utils.split
local rsubn = m_str_utils.gsub

-- geez diacritics
local XD = u(0x135F) -- combining gemination points above the character

-- letters and numerals      
local QF6    = u(0x1245) -- 6kˀāf ቅ, 1s 2s 2p preterite assimilation
local QWF6   = u(0x124A) -- 6kˀʷāf ቊ, 1s 2s 2p preterite assimilation
local KF6    = u(0x12AD) -- 6kāf ክ, 1s 2s 2p preterite assimilation
local KWF6   = u(0x12B5) -- 6kʷāf ኵ, 1s 2s 2p preterite assimilation
local GL6    = u(0x130D) -- 6gaməl ግ, 1s 2s 2p preterite assimilation
local GL6    = u(0x1315) -- 6gʷaməl ጕ, 1s 2s 2p preterite assimilation
local HYPHEN = u(0x0640)
local NS6    = u(0x1295) -- 6nahās = ን, 1p preterite assimilation
local WW6    = u(0x12CD) -- 6wāw = ው, weak consonant
local YN6    = u(0x12ED) -- 6yaman = ይ, weak consonant
local HY6    = u(0x1205) -- 6hoy = ህ, velar continuant or post-velar, vowel changes
local HT6    = u(0x1215) -- 6ħawt = ሕ, velar continuant or post-velar, vowel changes
local XM6    = u(0x1285) -- 6xam  = ኅ, velar continuant or post-velar, vowel changes
local XWM6   = u(0x128D) -- 6xʷam = ኍ, velar continuant or post-velar, vowel changes
local AF6    = u(0x12A5) -- 6ʔalf = እ, velar continuant or post-velar, vowel changes
local AN6    = u(0x12D5) -- 6ʕayn = ዕ, velar continuant or post-velar, vowel changes
local AF1    = u(0x12A0) -- 1ʔalf = አ, velar continuant or post-velar, vowel changes
local TW1	 = u(0x1270) -- 1taw = ተ, premorph for medio-passive stems
local TW4	 = u(0x1273) -- 4taw = ታ, variant premorph for medio-passive stems before 6th-series velar cont/post-velar
local ST6	 = u(0x1235) -- 4sat = ስ, for S stem in asta-, astaa-
local NN6	 = u(0x1295) -- 6nun = ን, for Nt stem

local SER1	 = "ሀለሐመሠረሰቀቈበተኀኈነአከኰወዐዘየደገጐጠጰጸፀፈፐ" -- radicals with series 1 vowel a
local SER2	 = "ሁሉሑሙሡሩሱቁቡቱኁኑኡኩዉዑዙዩዱጉጡጱጹፁፉፑ" -- radicals with series 2 vowel u
local SER3	 = "ሂሊሒሚሢሪሲቂቊቢቲኂኊኒኢኪኲዊዒዚዪዲጊጒጢጲጺፂፊፒ" -- radicals with series 3 vowel i
local SER4	 = "ሃላሓማሣራሳቃቋባታኃኋናኣካኳዋዓዛያዳጋጓጣጳጻፃፋፓ" -- radicals with series 4 vowel ā
local SER5   = "ሄሌሔሜሤሬሴቄቌቤቴኄኌኔኤኬኴዌዔዜዬዴጌጔጤጴጼፄፌፔ" -- radicals with series 5 vowel e
local SER6   = "ህልሕምሥርስቅቍብትኅኍንእክኵውዕዝይድግጕጥጵጽፅፍፕ" -- radicals with series 6 vowel ə or no vowel 
local SER7   = "ሆሎሖሞሦሮሶቆቦቶኆኖኦኮዎዖዞዮዶጎጦጶጾፆፎፖ" -- radicals with series 7 vowel u
local ALL	 = XD .. SER1 .. SER2 .. SER3 .. SER4 .. SER5 .. SER6 .. SER7 --all the allowable letters

-- syllabogram tables arranged by consonant
local HOY	 = {"ሀ", "ሁ", "ሂ", "ሃ", "ሄ", "ህ", "ሆ"} -- hoy
local LAW	 = {"ለ", "ሉ", "ሊ", "ላ", "ሌ", "ል", "ሎ"} -- law
local HAWT	 = {"ሐ", "ሑ", "ሒ", "ሓ", "ሔ", "ሕ", "ሖ"} -- hawt
local MAY	 = {"መ", "ሙ", "ሚ", "ማ", "ሜ", "ም", "ሞ"} -- may
local SAWT	 = {"ሠ", "ሡ", "ሢ", "ሣ", "ሤ", "ሥ", "ሦ"} -- sawt
local REES	 = {"ረ", "ሩ", "ሪ", "ራ", "ሬ", "ር", "ሮ"} -- rees
local SAT	 = {"ሰ", "ሱ", "ሲ", "ሳ", "ሴ", "ስ", "ሶ"} -- sat
local QAF	 = {"ቀ", "ቁ", "ቂ", "ቃ", "ቄ", "ቅ", "ቆ"} -- qaf
local QWAF	 = {"ቈ", "ቊ", "ቋ", "ቌ", "ቍ"} -- qwaf
local BET	 = {"በ", "ቢ", "ቡ", "ባ", "ቤ", "ብ", "ቦ"} -- bet
local TAW	 = {"ተ", "ቲ", "ቱ", "ታ", "ቴ", "ት", "ቶ"} -- taw
local HARM	 = {"ኀ", "ኁ", "ኂ", "ኃ", "ኄ", "ኅ", "ኆ"} -- harm
local HWARM	 = {"ኈ", "ኊ", "ኋ", "ኌ", "ኍ"} -- hwarm
local NAHAS	 = {"ነ", "ኑ", "ኒ", "ና", "ኔ", "ን", "ኖ"} -- nahas, triggers total assimilation with 1p preterite suffix -na
local ALF	 = {"አ", "ኡ", "ኢ", "ኣ", "ኤ", "እ", "ኦ"} -- alf
local KAF	 = {"ከ", "ኩ", "ኪ", "ካ", "ኬ", "ክ", "ኮ"} -- kaf
local KWAF	 = {"ኰ", "ኲ", "ኳ", "ኴ", "ኵ"} -- kwaf
local WAW	 = {"ወ", "ዉ", "ዊ", "ዋ", "ዌ", "ው", "ዎ"} -- waw
local AYN	 = {"ዐ", "ዑ", "ዒ", "ዓ", "ዔ", "ዕ", "ዖ"} -- ayn
local ZAY	 = {"ዘ", "ዙ", "ዚ", "ዛ", "ዜ", "ዝ", "ዞ"} -- zay
local YAMAN	 = {"የ", "ዩ", "ዪ", "ያ", "ዬ", "ይ", "ዮ"} -- yaman
local DENT	 = {"ደ", "ዱ", "ዲ", "ዳ", "ዴ", "ድ", "ዶ"} -- dent
local GAML	 = {"ገ", "ጉ", "ጊ", "ጋ", "ጌ", "ግ", "ጎ"} -- gaml
local GWAML  = {"ጐ", "ጒ", "ጓ", "ጔ", "ጕ"} -- gwaml
local TAYT	 = {"ጠ", "ጡ", "ጢ", "ጣ", "ጤ", "ጥ", "ጦ"} -- tayt
local PAYT	 = {"ጰ", "ጱ", "ጲ", "ጳ", "ጴ", "ጵ", "ጶ"} -- payt
local SADAY	 = {"ጸ", "ጹ", "ጺ", "ጻ", "ጼ", "ጽ", "ጾ"} -- saday
local DAPPA  = {"ፀ", "ፁ", "ፂ", "ፃ", "ፄ", "ፅ", "ፆ"} -- dappa
local AF	 = {"ፈ", "ፉ", "ፊ", "ፋ", "ፌ", "ፍ", "ፎ"} -- af
local PA	 = {"ፐ", "ፑ", "ፒ", "ፓ", "ፔ", "ፕ", "ፖ"} -- pa

-------------------------------------------------------------------------------
--                                Utility functions                          --
-------------------------------------------------------------------------------
-- checks the series to which a syllabogram belongs
local function series_check(letter)
	local sernum = 0
	if rmatch(letter, SER1) then
		sernum = 1
	elseif rmatch(letter, SER2) then
		sernum = 2
	elseif rmatch(letter, SER3) then
		sernum = 3
	elseif rmatch(letter, SER4) then
		sernum = 4
	elseif rmatch(letter, SER5) then
		sernum = 5
	elseif rmatch(letter, SER6) then
		sernum = 6
	elseif rmatch(letter, SER7) then
		sernum = 7
	end
	return sernum
end
-- given a syllabogram, returns the desired syllabogram of the same consonant
-- e.g., given yə, get ya
local function syllabogram(letter, number) 
	local retsyl = ""
	local sernum = series_check(letter)
	
	if letter == HOY then
		retsyl = HOY
	elseif letter == LAW then
		retsyl = LAW
	elseif letter == HAWT then
		retsyl = HAWT
	elseif letter == MAY then
		retsyl = MAY
	elseif letter == SAWT then
		retsyl = SAWT
	elseif letter == REES then
		retsyl = REES
	elseif letter == SAT then
		retsyl = SAT
	elseif letter == QAF then
		retsyl = QAF
	elseif letter == BET then
		retsyl = BET
	elseif letter == TAW then
		retsyl = TAW
	elseif letter == HARM then
		retsyl = HARM
	elseif letter == NAHAS then
		retsyl = NAHAS
	elseif letter == ALF then
		retsyl = ALF
	elseif letter == KAF then
		retsyl = KAF
	elseif letter == WAW then
		retsyl = WAW
	elseif letter == AYN then
		retsyl = AYN
	elseif letter == ZAY then
		retsyl = ZAY
	elseif letter == YAMAN then
		retsyl = YAMAN
	elseif letter == DENT then
		retsyl = DENT
	elseif letter == GAML then
		retsyl = GAML
	elseif letter == TAYT then
		retsyl = TAYT
	elseif letter == PAYT then
		retsyl = PAYT
	elseif letter == SADAY then
		retsyl = SADAY
	elseif letter == DAPPA then
		retsyl = DAPPA
	elseif letter == AF then
		retsyl = AF
	elseif letter == PA then
		retsyl = PA
	elseif sernum == 1 then
		if number == 1 then
			if letter == QWAF then 
				retsyl = QWAF
			elseif letter == HWARM  then
				retsyl = HWARM
			elseif letter == KWAF  then
				retsyl = KWAF
			elseif letter == GWAF  then
				retsyl = GWAF
			end
		else
			if letter == QWAF then 
				retsyl = QWAF
			elseif letter == HWARM  then
				retsyl = HWARM
			elseif letter == KWAF  then
				retsyl = KWAF
			elseif letter == GWAF  then
				retsyl = GWAF
			end
		end
	elseif sernum > 1 then
		if number == 1 then
			if letter == QWAF then
				retsyl = QWAF
			elseif letter == HWARM then
				retsyl = HWARM
			elseif letter == KWAF then
				retsyl = KWAF
			elseif letter == GWAML then
				retsyl = GWAML
			end
		else 
			if letter == QWAF then
				retsyl = QWAF
			elseif letter == HWARM then
				retsyl = HWARM
			elseif letter == KWAF then
				retsyl = KWAF
			elseif letter == GWAML then
				retsyl = GWAML
			end
		end
	end
	return retsyl
end

local rsplit = m_str_utils.split
local rsubn = m_str_utils.gsub

local separator_langs = { }
local template_preview_per_langcode = {  }
local lang

local function link(term, alt, id)
	if term == "" or term == "—" then
		return term
	else
		return m_links.full_link({
			term = term,
			alt = alt,
			lang = lang,
			id = id,
		})
	end
end

local function validateRoot(rootTable, joined_root)
	if type(rootTable) ~= "table" then
		error("rootTable is not a table", 2)
	end
	
	local len = #rootTable

	if len < 3 then
		error("Root must have at least three radicals.")
	end

	for i, letter in ipairs(rootTable) do
		if mw.ustring.len(letter) > 1 then
			error("'" .. letter .. "', the " .. ordinal ..
				" letter in the root '" .. joined_root ..
				"' should be a single letter.")
		end
	end
end

function export.root(frame)
	local output = {}
	local categories = {}
	local title = mw.title.getCurrentTitle()
	local namespace = title.nsText
    local fulltitle = title.fullText

	if frame.args then
		lang = require("Module:languages").getByCode(frame.args)
	else
		error("Please provide a language code.")
	end

	local subpage = "Appendix:" .. lang:getCanonicalName() .. " roots/"
	local fulltitle = rsubn(fulltitle, rsubn(subpage, "()", "%%%1"), "")

	local params = {
		 = { list = true },
		 = { type = "boolean" },
		 = { type = "boolean" },
		 = { type = "boolean" },
		 = {}
	}

	local args = require("Module:parameters").process(frame:getParent().args, params)
	local rootLetters = {}
	local roots = args
	
	local plain = args
	if frame.args then
		plain = true
	end

	local langCode = lang:getCode()

	local separator = "-"
	if separator_langs then
		separator = " "
	else
		separator = "-"
	end

	local roots_len = #roots

	if #roots == 0 and namespace == "Template" then
		if template_preview_per_langcode ~= nil then
			table.insert(rootLetters, rsplit(template_preview_per_langcode, separator))
		else
			table.insert(rootLetters, rsplit("ከ-ተ-በ", separator))
		end
	elseif #roots ~= 0 then
		for _, root in ipairs(roots) do
			table.insert(rootLetters, rsplit(root, separator))
		end
	else
		table.insert(rootLetters, rsplit(fulltitle, separator))
	end

	local joined_roots = {}
	for i, rootLetter in ipairs(rootLetters) do
		table.insert(joined_roots, table.concat(rootLetter, separator))
		validateRoot(rootLetter, joined_roots)
	end

	local sense = args
	local sense_formatted = ""
	if sense ~= nil then
		sense_formatted = " (" .. sense .. ") "
	end

	if fulltitle == joined_roots then
		if namespace == "" then
			error("The root page should be in the Appendix namespace. Please move it to : [[" ..
			subpage .. joined_roots .. "]]")
		end

		if roots_len > 1 then
			error("There should be only one root.")
		end

		table.insert(output,
			m_headword.full_headword({ lang = lang, pos_category = "roots", categories = {}, heads = { fulltitle }, nomultiwordcat = true, noposcat = true }))

		if args then
			return table.concat(output)
		else
			return table.concat(output) .. table.concat(categories)
		end
	else
		local link_texts = {}
		local term_counts = {}

		for i, joined_root in ipairs(joined_roots) do
			local link_text = subpage .. joined_root
			table.insert(link_texts, link(link_text, joined_root .. sense_formatted, sense))
			table.insert(
				categories,
				m_utilities.format_categories(
					{ lang:getCanonicalName() .. " terms belonging to the root " .. joined_root .. sense_formatted },
					lang)
			)
			table.insert(term_counts,
				mw.site.stats.pagesInCategory(
					lang:getCanonicalName() .. " terms belonging to the root " .. joined_root .. sense_formatted, "pages")
			)
		end

		if args or plain then
			return table.concat(link_texts, ", ")
		else
			local link_text_output = ""
			for i, link_text in ipairs(link_texts) do
				link_text_output = link_text_output .. '<tr><td>' ..
					link_text ..
					"</td></tr><tr><td>[[:Category:" ..
					lang:getCanonicalName() ..
					" terms belonging to the root " ..
					joined_roots ..
					sense_formatted ..
					"|" ..
					term_counts ..
					" term" .. (term_counts == 1 and "" or "s") .. "]]</td></tr>"
			end
			return
				'<table class="wikitable" style="float: right; clear: right; text-align: center;"><tr><th>[[w:Semitic root|Root' ..
				(#term_counts == 1 and "" or "s") .. ']]</th></tr>' .. link_text_output ..
				'</table>' .. table.concat(categories)
		end
	end
end

return export