မဝ်ဂျူ:tr-verb form of

နူ ဝိက်ရှေန်နရဳ

This module powers {{tr-verb form of}}.


local export = {}

local m_harmony = require("Module:tr-harmony")
local m_form_of = require("Module:form of")

local lang = require("Module:languages").getByCode("tr")

function export.show(frame)
   	local args = require "Module:parameters".process(frame:getParent().args, {
		[1] = { required = true },
		["title"] = { default = nil },
	})

	local lemma = args[1]
	local title = args["title"] or mw.title.getCurrentTitle().text
	if not mw.ustring.match(lemma, "m[ae]k$") then
		error("lemma form must end in -mak or -mek")
	end
	
	local stem = lemma:sub(1, -4)
	local soft_stem = m_harmony.soften(stem)
	local stem_last = mw.ustring.match(stem, "(%w+)$")
	local one_syllable = not mw.ustring.match(stem_last, "[" .. m_harmony.vowels .. "][^" .. m_harmony.vowels .. "]+[" .. m_harmony.vowels .. "]")
	local etmek_style = mw.ustring.match(stem, "et$")
	local could_have_2_way_aorist = one_syllable or etmek_style
	
	local last_vowel = m_harmony.get_last_vowel(stem)
	local A = m_harmony.get_2_way_harmony(last_vowel)
	local I = m_harmony.get_4_way_harmony(last_vowel)
	local ends_with_vowel = m_harmony.ends_with_vowel(stem)
	local Y = ends_with_vowel and "y" or ""
	local ends_with_voiceless_consonant = m_harmony.ends_with_voiceless_consonant(stem)
	local D = ends_with_voiceless_consonant and "t" or "d"
	
	forms = {}
	local terminfo = {
		lang = lang,
		term = lemma,
	}
	
	function add_form(suffixes, tags)
		if mw.ustring.match(suffixes, "^R") then
			if ends_with_vowel then
				suffixes = mw.ustring.gsub(suffixes, "^R", "r")
			else
				add_form(mw.ustring.gsub(suffixes, "^R", "Ir"), tags)
				if could_have_2_way_aorist then
					add_form(mw.ustring.gsub(suffixes, "^R", "Ar"), tags)
				end
				return
			end
		end
		suffixes =  mw.ustring.gsub(suffixes, "^Y", Y)
		suffixes =  mw.ustring.gsub(suffixes, "^D", D)
		vowel = last_vowel
		while true do
			first_A = mw.ustring.find(suffixes, "A")
			first_I = mw.ustring.find(suffixes, "I")
			if not first_A and not first_I then
				break
			end
			first = math.min(first_A or first_I + 1, first_I or first_A + 1)
			if first_A == first then
				vowel = m_harmony.get_2_way_harmony(vowel)
				suffixes = mw.ustring.gsub(suffixes, "A", vowel, 1)
			else
				vowel = m_harmony.get_4_way_harmony(vowel)
				suffixes = mw.ustring.gsub(suffixes, "I", vowel, 1)
			end
		end
		
		forms[stem .. suffixes] = tags
		if m_harmony.starts_with_vowel(suffixes) then
			forms[soft_stem .. suffixes] = tags
		end
	end
	
	-- imperative
	add_form("",         { "2", "s", "imp" })
	add_form("sIn",      { "3", "s", "imp" })
	add_form("YIn",      { "2", "p", "imp" })
	add_form("YInIz",    { "polite", "2", "p", "imp" })
	add_form("sInlAr",   { "3", "p", "imp" })
	add_form("mA",       { "2", "s", "neg", "imp" })
	add_form("mAsIn",    { "3", "s", "neg", "imp" })
	add_form("mAyIn",    { "2", "p", "neg", "imp" })
	add_form("mAyInIz",  { "polite", "2", "p", "neg", "imp" })
	add_form("mAsInlAr", { "3", "p", "neg", "imp" })
	
	-- indicative
	--- aorist
	add_form("RIm",    { "1", "s", "ind", "aor" })
	add_form("RsIn",   { "2", "s", "ind", "aor" })
	add_form("R",      { "3", "s", "ind", "aor" })
	add_form("RIz",    { "1", "p", "ind", "aor" })
	add_form("RsInIz", { "2", "p", "ind", "aor" })
	add_form("RlAr",   { "3", "p", "ind", "aor" })
	
	add_form("mAm",      { "1", "s", "ind", "neg", "aor" })
	add_form("mAzsIn",   { "2", "s", "ind", "neg", "aor" })
	add_form("mAz",      { "3", "s", "ind", "neg", "aor" })
	add_form("mAyIz",    { "1", "p", "ind", "neg", "aor" })
	add_form("mAzsInIz", { "2", "p", "ind", "neg", "aor" })
	add_form("mAzlAr",   { "3", "p", "ind", "neg", "aor" })
	
	--- အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ
	add_form("DIm",   { "1", "s", "ind", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	add_form("DIn",   { "2", "s", "ind", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	add_form("DI",    { "3", "s", "ind", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	add_form("DIk",   { "1", "p", "ind", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	add_form("DInIz", { "2", "p", "ind", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	add_form("DIlAr", { "3", "p", "ind", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	
	add_form("mAdIm",   { "1", "s", "ind", "neg", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	add_form("mAdIn",   { "2", "s", "ind", "neg", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	add_form("mAdI",    { "3", "s", "ind", "neg", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	add_form("mAdIk",   { "1", "p", "ind", "neg", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	add_form("mAdInIz", { "2", "p", "ind", "neg", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	add_form("mAdIlAr", { "3", "p", "ind", "neg", "အတိတ်ကာလမကော်ခဴစလ္ၚာလ္ၚာ" })
	
	--- future
	add_form("YAcAğIm",    { "1", "s", "ind", "fut" })
	add_form("YAcAksIn",   { "2", "s", "ind", "fut" })
	add_form("YAcAk",      { "3", "s", "ind", "fut" })
	add_form("YAcAğIz",    { "1", "p", "ind", "fut" })
	add_form("YAcAksInIz", { "2", "p", "ind", "fut" })
	add_form("YAcAklAr",   { "3", "p", "ind", "fut" })
	
	add_form("mAyAcAğIm",    { "1", "s", "ind", "neg", "fut" })
	add_form("mAyAcAksIn",   { "2", "s", "ind", "neg", "fut" })
	add_form("mAyAcAk",      { "3", "s", "ind", "neg", "fut" })
	add_form("mAyAcAğIz",    { "1", "p", "ind", "neg", "fut" })
	add_form("mAyAcAksInIz", { "2", "p", "ind", "neg", "fut" })
	add_form("mAyAcAklAr",   { "3", "p", "ind", "neg", "fut" })
	
	tags = forms[title]
	if tags then
		local categories = m_form_of.fetch_lang_categories(lang, tags, terminfo, "verb")
		return m_form_of.tagged_inflections({ tags = tags, terminfo = terminfo, terminfo_face = "term" }) ..
			require("Module:utilities").format_categories(categories, lang) -- , args["sort"] needed?
	else
		error("unknown verb form")
	end
end

return export