Module:az-common

From Wiktionary, the free dictionary
Jump to navigation Jump to search


local export = {}

local rfind = mw.ustring.find

local vowels = "aəeiıuüöoаәеиыуүөо"
local vowel = "[" .. vowels .. "]"

function export.getType(term)
	local last = mw.ustring.sub(term, -1)
	local second_to_last = mw.ustring.sub(term, -2, -2)
	local third_to_last = mw.ustring.sub(term, -3, -3)
	if rfind(last, vowel) then
		return last, nil
	elseif rfind(second_to_last, vowel) then
		if rfind(last, "[kqгк]") then
			return second_to_last, last
		else
			return second_to_last, "c"
		end
	elseif second_to_last == last then
		return third_to_last, "cc"
	else
		return third_to_last, "c"
	end
end

return export