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

local export = {}
local lang = require("Module:languages").getByCode("rmq")

--nouns
function export.show_noun(frame)
	local args = frame:getParent().args
	local data = {lang = lang, pos_category = "နာမ်", categories = {}, sort_key = args.sort, heads = {args.head}, genders, inflections = {}}
	local tracking_categories = {}
	
	--define variables

	local stem = mw.title.getCurrentTitle().text
	if args.head then --in case a different headword is specified
		stem = args.head
	end
	
	local short_stem = stem:sub(1, -2)
	local ending = ""

	--add gender
	local g, genders = args.g or args[1]
	if g == "m" then
		data.genders = { "m" }
	elseif g == "f" then
		data.genders = { "f" }
	elseif g == "both" then
		data.genders = { "m","f" }
	else
		data.genders = { "?" }
	end
	
	--find ending
	ending = stem:sub(-1)
	if	stem:sub(-2,-1) == "ay" then
		 stem = stem:sub(1, -3)
		 ending = "ay"
	elseif stem:sub(-2,-1) == "oy" then
		stem = stem:sub(1, -3)
		ending = "oy"
	elseif stem:sub(-2,-1) == "uy" then
		stem = stem:sub(1,-3)
		ending = "uy"
	elseif stem:sub(-2,-1) == "ó" then
		stem = stem:sub(1,-3)
		ending = "ó"
	elseif stem:sub(-2,-1) == "í" then
		ending = "í"
	elseif ending == "y" then
		stem = stem:sub(1,-2)
	end

	--generate plurals
	local pl = args.pl or args[2]
	if pl then
		if pl == "-" then
			
			data.inflections = {{label = "တော်ဟွံမာန်"}}
		else
			data.inflections = {{label = "ကိုန်ဗဟုဝစ်", pl}}
		end
	else 
		if ending == "ay" then
			data.inflections = {{label = "ကိုန်ဗဟုဝစ်", stem .. "áes"}}
		elseif ending == "oy" then
			data.inflections = {{label = "ကိုန်ဗဟုဝစ်", stem .. "ayes"}}
		elseif ending == "uy" then
			data.inflections = {{label = "ကိုန်ဗဟုဝစ်", stem .. "úes"}}
		elseif ending == "y" then
			data.inflections = {{label = "ကိုန်ဗဟုဝစ်", stem .. "ís"}}
		elseif ending == "ó" then
			data.inflections = {{label = "ကိုန်ဗဟုဝစ်", stem .. "és" }}
		elseif ending == "í" then
			data.inflections = {{label = "ကိုန်ဗဟုဝစ်", stem .. "as"}}
		elseif ('aeiouáé'):match(ending) then
			data.inflections = {{label = "ကိုန်ဗဟုဝစ်", stem .. "s"}}
		else
			data.inflections = {{label = "ကိုန်ဗဟုဝစ်", stem .. "es"}}
		end
	end

	return require("Module:headword").full_headword(data) ..
		require("Module:utilities").format_categories(tracking_categories, lang, args.sort)
end

return export