Module:ine-common

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

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local short_to_long = {
	 = "ā",
	 = "ē",
	 = "ī",
	 = "ō",
	 = "ū",
	
	 = "ā́",
	 = "ḗ",
	 = "ī́",
	 = "ṓ",
	 = "ū́",
}

local acute_to_none = {
	 = "a",
	 = "e",
	 = "i",
	 = "o",
	 = "u",
		
	 = "ē",
	 = "ō",
		
	 = "",
}

local colors = {
	 = {
		 = "a",
		 = "á",
	},
	 = {
		 = "o",
		 = "ó",
	}
}

function export.lengthen(text)
	text = mw.ustring.gsub(text, ".", short_to_long)
	
	return text
end

function export.destress(text)
	text = mw.ustring.gsub(text, ".", acute_to_none)
	
	return text
end

function export.laryngeal_color(text)
	local coloring_laryngeal = "(h)"
	local vowel = "()"
	
	-- Not sure what the precedence is here. Does e.g. h₃eh₂ color to o or a?
	text = mw.ustring.gsub(text, coloring_laryngeal .. vowel,
		function(laryngeal, vowel)
			return laryngeal .. colors
		end)
	text = mw.ustring.gsub(text, vowel .. coloring_laryngeal,
		function(vowel, laryngeal)
			return colors .. laryngeal
		end)
	
	return text
end

local function syllabify(text)
	text = mw.ustring.gsub(text, "w", "u")
	text = mw.ustring.gsub(text, "y", "i")
	text = mw.ustring.gsub(text, "()", "%1̥")
	
	return text
end

local function desyllabify(text)
	text = mw.ustring.gsub(text, "u", "w")
	text = mw.ustring.gsub(text, "i", "y")
	text = mw.ustring.gsub(text, "̥", "")
	
	return text
end

function export.add_ending(stem, ending, ending_unstr, do_szemerenyi)
	-- Destress the ending if necessary
	if mw.ustring.find(stem, "") then
		if ending_unstr then
			ending = ending_unstr
		else
			ending = export.destress(ending)
		end
	end
	
	-- Desyllabify sonorants next to vowels
	if (mw.ustring.find(ending, "^") or mw.ustring.find(ending, "^̥")) and mw.ustring.find(stem, "$") then
		local rest, sonorants = mw.ustring.match(stem, "^(.-)(+)$")
		
		sonorants = desyllabify(sonorants)
		sonorants = mw.text.split(sonorants, "", true)
		
		for i = #sonorants - 1, 1, -2 do
			sonorants = syllabify(sonorants)
		end
		
		if mw.ustring.find(rest, "$") then
			sonorants = desyllabify(sonorants)
		end
		
		stem = rest .. table.concat(sonorants)
	end
	
	if mw.ustring.find(stem, "$") then
		ending = mw.ustring.gsub(ending, "^()̥", "%1")
		ending = mw.ustring.gsub(ending, "^i", "y")
		ending = mw.ustring.gsub(ending, "^u", "w")
	end
	
	local word = stem .. ending
	
	-- Delabialization
	word = mw.ustring.gsub(word, "ʷ()", "%1")
	word = mw.ustring.gsub(word, "()ʷ", "%1")
	
	-- Stang's law
	word = mw.ustring.gsub(word, "m̥$", export.lengthen)
	word = mw.ustring.gsub(word, "()m̥$", "%1m")
	
	word = mw.ustring.gsub(word, "h₂m̥$", export.laryngeal_color)
	word = mw.ustring.gsub(word, "h₂m̥$", export.lengthen)
	word = mw.ustring.gsub(word, "()h₂m̥$", "%1m")
	
	word = mw.ustring.gsub(word, "(y)i$", export.lengthen)
	
	-- Szemerényi's law
	word = mw.ustring.gsub(word, "()nh₂$", export.lengthen)
	word = mw.ustring.gsub(word, "()h₂$", export.lengthen)
	word = mw.ustring.gsub(word, "(r)d$", export.lengthen)
	
	if do_szemerenyi then
		word = mw.ustring.gsub(word, "()ns$", export.lengthen)
		word = mw.ustring.gsub(word, "()s$", export.lengthen)
		word = mw.ustring.gsub(word, "(óy)s$", export.lengthen)
	end
	
	-- Laryngeal deletion
	word = mw.ustring.gsub(word, "()h()", "%1%2")
	word = mw.ustring.gsub(word, "()H()", "%1%2")
	
	word = mw.ustring.gsub(word, "()h()", "%1%2")
	word = mw.ustring.gsub(word, "()H()", "%1%2")
	
	-- Degemination
	word = mw.ustring.gsub(word, "ss", "s")
	
	word = mw.ustring.gsub(word, "iy()", "ī%1")
	word = mw.ustring.gsub(word, "íy()", "ī́%1")
	
	word = mw.ustring.gsub(word, "uw()", "ū%1")
	word = mw.ustring.gsub(word, "úw()", "ū́%1")
	
	return word
end

return export