Jump to content

Module:Ga-common

Frae Wikipedia, the free beuk o knawledge
local export = {}

local eclipsis_prefixes = {
	["b"] = "m",
	["c"] = "g",
	["d"] = "n",
	["f"] = "bh",
	["g"] = "n",
	["p"] = "b",
	["t"] = "d",
}

function export.mutations(word, tag)
	local ret = {normal = word, len = word, ecl = word, an = word, tpro = word, hpro = word}
	
	local word_l = mw.ustring.lower(word)
	
	if tag ~= "nolen" then
		if mw.ustring.find(word_l, "^[bcdfgmpt]") then
			ret.len = mw.ustring.gsub(word, "^(.)", "%1h")
		elseif mw.ustring.find(word_l, "^s[aeiouáéíóúlnr]") then
			ret.len = mw.ustring.gsub(word, "^(.)", "%1h")
			ret.an = "t" .. word
		end
	end
	
	if eclipsis_prefixes[mw.ustring.sub(word_l, 1, 1)] then
		ret.ecl = eclipsis_prefixes[mw.ustring.sub(word_l, 1, 1)] .. word
	end
	
	if mw.ustring.find(word, "^[aeiouáéíóú]") then
		ret.ecl  = "n-" .. word
		ret.hpro = "h" .. word
		
		-- Masculine singular nouns have different lenition after the article "an"
		if tag == "msn" then
			ret.tpro = "t-" .. word
		end
	elseif mw.ustring.find(word, "^[AEIOUÁÉÍÓÚ]") then
		ret.ecl  = "n" .. word
		ret.hpro = "h" .. word
		
		-- Masculine singular nouns have different lenition after the article "an"
		if tag == "msn" then
			ret.tpro = "t" .. word
		end
	end
	
	return ret
end

return export