မာတိကာသို့ ခုန်သွားရန်

မဝ်ဂျူ:ka-headword

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

Documentation for this module may be created at မဝ်ဂျူ:ka-headword/doc

local export = {}

local lang = require("Module:languages").getByCode("ka")
local m_headword = require("Module:headword")

pos_functions = {}

local forms = {}
local template = [===[<div class="NavFrame" style="float: right; min-width: 290px; max-width: 40%;">
<div class="NavHead">[[:en:Appendix:Georgian adjectives#adjectival declension|ဗီုပြၚ်နာမဝိသေသနလဟုတ်စှ်ေကၠုၚ်]] of {pagename}</div>
<div class="NavContent">

{| border="1px solid #505050" style="border-collapse:collapse; background:#FAFAFA; text-align:center; width:100%" class="inflection-table"
|-
! style="background:#BBC9D0; width: 100px;" | တၚ်ကယျာန်ပါ်ပါဲ
! style="background:#BBC9D0" | နာမဝိသေသန
|-
! style="background:#BBC9D0" | စရၚ်ယၟုတုပ်၊ ဗဳဇဂကူ၊ ကပေါတ်ကညောတ်ကရိယာ
| {nominative}
|-
! style="background:#BBC9D0" | မကယျာန်ပါ်ပါဲ
| {ergative}
|-
! style="background:#BBC9D0" | ပြကမ္မကာရက၊ ညံၚ်ကြိယာဝိသေသန
| {dative}
|-
! style="background:#BBC9D0" | ရမျာၚ်ဂယိုၚ်လမျီု
| {vocative}
|}</div></div>]===]


function get_adjectival_declension()
	local make_link = require("Module:links").full_link

	local term = mw.title.getCurrentTitle().text
	local erg = mw.ustring.sub(term, 0, -2) .. "მა"
	local dat = mw.ustring.sub(term, 0, -2)
	local voc = mw.ustring.sub(term, 0, -2) .. "ო"
	
	local last = mw.ustring.sub(term, -1, -1)
	local beforeLast = mw.ustring.sub(term, -2, -2)
	if mw.ustring.match(last, "[აეოუ]") or mw.ustring.match(beforeLast, "[აეიოუ]") then
		return [===[<div class="NavFrame" style="float: right; width:150px;"><div class="NavHead">indeclinable</div></div>]===]
	end
	forms["pagename"] = term
	forms["nominative"] = make_link({lang = lang, term = term})
	forms["ergative"] = make_link({lang = lang, term = erg})
	forms["dative"] = make_link({lang = lang, term = dat})
	forms["vocative"] = make_link({lang = lang, term = voc})
	return require("Module:string utilities").format(template, forms)
end

function export.show(frame)
	local args = frame:getParent().args
	local poscat = frame.args[1]

	local data = {lang = lang, pos_category = poscat, categories = {}, heads = {args["term"] or args["head"]}, inflections = {}}
	
	return pos_functions[poscat](args, data)
end

pos_functions["နာမဝိသေသန"] = function(args, data)
	if args[1] == "-" then --then hope there is no diminutive
		table.insert(data.inflections, {label = "[[Appendix:Glossary#comparable|ပတုပ်ရံၚ်]]ဟွံမာန်"})
		
	else
		local diminutive = args[1]
		local comparative = args["comp"] or "[[უფრო]] " .. (args["term"] or mw.title.getCurrentTitle().text)
		local superlative = args["sup"] or "[[ყველაზე]] " .. (args["term"] or mw.title.getCurrentTitle().text)
	
		table.insert(data.inflections, {label = "[[en:Appendix:Glossary#comparative|ပတုပ်ရံၚ်]]", comparative})
		table.insert(data.inflections, {label = "[[en:Appendix:Glossary#superlative|သဒ္ဒာ]]", superlative})
		if diminutive then
			table.insert(data.inflections, {label = "[[en:Appendix:Glossary#diminutive|လဟုတ်စှ်ေ]]", diminutive})
		end
	end
	
	return get_adjectival_declension() .. m_headword.full_headword(data)
end

function getModernPlural(term) --detect ჟოკეი too
	local lastLetter = mw.ustring.sub(term, -1)
	if lastLetter == "ი" or lastLetter == "ა" then 
		return mw.ustring.sub(term, 0, -2) .. "ები"
	elseif lastLetter == "ე" or lastLetter == "ო" or lastLetter == "უ" then
		return term .. "ები"
	end
end

function getArchaicPlural(term)
	local lastLetter = mw.ustring.sub(term, -1)
	if lastLetter == "ი" then 
		return mw.ustring.sub(term, 0, -2) .. "ნი"
	else
		return term .. "ნი"
	end
end

pos_functions["နာမ်မကိတ်ညဳ"] = function(args, data)
	if args[1] ~= nil then
		if args[1] == "-" then --არც გაატრაკო ტო
			table.insert(data.inflections, {label = "[[Appendix:Glossary#uncountable|တော်ဟွံမာန်]]"})
		else
			table.insert(data.inflections, {label = "ကိုန်ဗဟုဝစ်", args[1]})
			
		end
	end
	return m_headword.full_headword(data)
end

pos_functions["နာမ်"] = function(args, data)
	local a, b, c = args[1], args[2], args[3]
	local wordArg = nil

	local isUncountAndCount = a == "~" or b == "~" or c == "~"
	local hasDash = a == "-" or b == "-" or c == "-"
	local hasQuestion = a == "?" or b == "?" or c == "?"
	if hasQuestion then
		return m_headword.full_headword(data)
	end
	
	if a and mw.ustring.match(a, "[ა-ჰ]") then wordArg = a end
	if b and mw.ustring.match(b, "[ა-ჰ]") then wordArg = b end
	if c and mw.ustring.match(c, "[ა-ჰ]") then wordArg = c end

	local hasArchaic = a == "+" or b == "+" or c == "+"
	local hasPlural = a == "0" or b == "0" or c == "0" or not hasDash or wordArg
	local archaic = hasArchaic and getArchaicPlural(args["term"] or mw.title.getCurrentTitle().text) or nil
	local plural = hasPlural and (wordArg or getModernPlural(args["term"] or mw.title.getCurrentTitle().text)) or nil

	if hasDash then
		if plural or archaic then
			table.insert(data.inflections, {label = "usually [[Appendix:Glossary#uncountable|တော်ဟွံမာန်]]"})
		else
			table.insert(data.inflections, {label = "[[Appendix:Glossary#uncountable|တော်ဟွံမာန်]]"})
		end
	else
		
		if isUncountAndCount then
			table.insert(data.inflections, {label = "[[Appendix:Glossary#uncountable|တော်ဟွံမာန်]] and [[Appendix:Glossary#countable|တော်မာန်]]"})
		end
	end

	if hasDash or isUncountAndCount then
		
	end

	if plural then
		table.insert(data.inflections, {label = "ကိုန်ဗဟုဝစ်", plural, accel = {form = "nom|p"}})
	end
	if archaic then
		table.insert(data.inflections, {label = "ကိုန်ဗဟုဝစ်ဗီုပြၚ်တြေံတြဟ်", archaic})
	end
	
	return m_headword.full_headword(data)
end

return export