Module:akk-common

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


local export = {}

local cuneiforms = mw.loadData("Module:akk-common/data")

function export.assimilate(pattern)
	local replace = {
		 = "tt",
		 = "dd",
		 = "ṭṭ",
		 = "zz",
		 = "ss",
		 = "ṣṣ"
	}
	return replace or pattern
end

local to_OB = {
	 = "pi₂",
	 = "pe₂",
	 = "qu₂",
	 = "qa₂",
	 = "qi₂",
	 = "ṭu₂"
}
function export.to_long(vowel)
	local table = {
		 = "ā",
		 = "ē",
		 = "ī",
		 = "ū",
	}
	return table or vowel
end

function export.to_double_long(vowel)
	local table = {
		 = "â",
		 = "ê",
		 = "î",
		 = "û",
	}
	return table or vowel
end

function export.to_short(vowel)
	local table = {
		 = "a",
		 = "e",
		 = "i",
		 = "u",
		 = "a",
		 = "e",
		 = "i",
		 = "u",
	}
	return table or vowel
end

local function is_vowel(char)
	local table = {
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
	}
	return table ~= nil
end
local Stream = {}

function Stream:new(word)
	local object = setmetatable({}, { __index = self })
	object.index = 0
	object.word = word
	return object
end

function Stream:peek(step)
	return mw.ustring.sub(self.word, self.index + (step or 0), self.index + (step or 0))
end

function Stream:next()
	self.index = self.index + 1
	return self:peek()
end

function Stream:is_vowel(offset)
	return is_vowel(self:peek(offset))
end

function Stream:is_geminate()
	-- VCC or VC$
	local v1 = self:peek(1) == self:peek(2)
	-- CVCC or CVC$
	local v2 = self:peek(2) == self:peek(3)
	if self:is_vowel() then
		return v1 and self:peek(2) ~= ""
	else
		return v2 and self:peek(2) ~= ""
	end
end

function Stream:is_closed()
	local v = {
		self:is_vowel(),
		self:is_vowel(1),
		self:is_vowel(2),
		self:is_vowel(3),
	}
	local e = {
		self:peek() == "",
		self:peek(1) == "",
		self:peek(2) == "",
		self:peek(3) == "",
	}
	-- VCC or VC$
	local v1 = v and not v and (not v or e)
	local e1 = not e and not e
	-- CVCC or CVC$
	local v2 = not v and v and not v and (not v or e)
	local e2 = not e and not e and not e
	return (v1 and e1) or (v2 and e2)
end

function Stream:syll_phonetic()
	local syll = {}
	local i = #syll
	while self:next() ~= "" do
		i = #syll + 1
		if self:is_closed() then
			syll = self:peek() .. self:next()
			if self:is_vowel() then
				syll = syll .. self:next()
			end
		elseif self:is_vowel() then
			syll = self:peek()
		else
			syll = self:peek() .. self:next()
		end
	end
	return syll
end

-- this function will syllabify an Akkadian word
-- phonetically. It is intended to be used for
-- inflection table modules that will occationally need
-- to do this kind of work. E.G
--		"parasum" => "pa" - "ra" - "sum"
--		"abriqqu" => "ab" - "riq" - "qum"
function export.syllabify_phonetic(word)
	local stream = Stream:new(word)
	return stream:syll_phonetic()
end

function Stream:syll()
	local syll = {}
	local i = #syll
	while self:next() ~= "" do
		i = #syll + 1
		local p = self:peek()
		if i == 1 and (p == "a" or p == "e") and self:is_closed() then
			syll = p
			i = #syll + 1
		end
		if self:is_closed() then
			syll = self:peek() .. self:next()
			if self:is_vowel() then
				syll = self:peek() .. self:next()
			end
		elseif self:is_vowel() then
			syll = self:peek()
		else
			syll = self:peek() .. self:next()
		end
	end
	return syll
end

function export.syllable_is_closed(syll)
	return not export.is_vowel(mw.ustring.sub(syll, #syll))
end

local function syllabify(word)
	if word == "–" or word == "" then
		return { "–" }
	end
	local normalized = ""
	for char in mw.ustring.gmatch(word, ".") do
		normalized = normalized .. export.to_short(char)
	end
	local stream = Stream:new(normalized)
	return stream:syll()
end
-- this function returns a naive transliteration
-- for the word based of the broad transcription.
function export.naive_transliteration(word)
	local translit = nil
	for _, sign in ipairs(syllabify(word)) do
		if translit then
			translit = translit .. "-" .. (to_OB or sign)
		else
			translit = to_OB or sign
		end
	end
	translit = mw.ustring.gsub(translit, "tuum", "tum")
	translit = mw.ustring.gsub(translit, "luum", "lum")
	translit = mw.ustring.gsub(translit, "liim", "lim")
	translit = mw.ustring.gsub(translit, "laam", "lam")
	translit = mw.ustring.gsub(translit, "tiim", "tim")
	translit = mw.ustring.gsub(translit, "taam", "tam")
	return translit
end

-- This will transform a transcription into cuneiform
function export.from_transliteration(trans)
	local cuneiform = ""
	for sign in mw.ustring.gmatch(trans, "(+)?") do
		if not cuneiforms and sign ~= "–" then
			error("no cuneiform sign for " .. sign)
		end
		cuneiform = cuneiform .. (cuneiforms or sign)
	end
	return cuneiform
end

function export.from_transcription(word)
	if word == "–" then return word end
	local trans = export.naive_transliteration(word)
	return export.from_transliteration(trans)
end

export.is_vowel = is_vowel

return export