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

မဝ်ဂျူ:nn-verb-reg

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

Documentation for this module may be created at မဝ်ဂျူ:nn-verb-reg/doc

local export = {}

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

local function link(word, form)
	return "[[" .. form .. "]]"
end

local function make_root2(root)
	root = root:gsub("j$", "")
	return root:gsub("(.)%1$", "%1"), root
end
 
function export.main(frame)
	local PAGENAME = mw.title.getCurrentTitle().text
	local args = frame:getParent().args
	local class = frame.args[1]  
	local length = PAGENAME:len()
	local root = PAGENAME:gsub("[ae]$", "")
	
	local data = {lang = lang, pos_category = "ကြိယာ", categories = {}, inflections = {}}
	local root2, root2_imp
	
	if class == '1' then
		present_tense = root .. 'ar'
		past_tense = root .. 'a'
		past_participle = root .. 'a'
		passive_infinitive = root .. 'ast'
		present_participle =  root .. 'ande'
		imperative = root
	end    
	if class == '2' then
		root2, root2_imp = make_root2(root)

		present_tense = root .. 'er'
		past_tense = root2 .. 'te'
		past_participle = root2 .. 't'
		passive_infinitive = root .. 'ast'
		present_participle = root .. 'ande'
		imperative = root2_imp
	end
	if class == '12' or class == '21' then
		root2, root2_imp = make_root2(root)
		
		present_tense = link(PAGENAME, root .. 'ar') .. '/' .. link(PAGENAME, root .. 'er')
		past_tense = link(PAGENAME, root .. 'a') .. '/' .. link(PAGENAME, root2 .. 'te')
		past_participle = link(PAGENAME, root .. 'a') .. '/' .. link(PAGENAME, root2 .. 't')
		passive_infinitive = link(PAGENAME, root .. 'ast') 
		present_participle = link(PAGENAME, root .. 'ande') 
		imperative = link(PAGENAME, root) 
	end
	if class == '3' then
		root2, root2_imp = make_root2(root)
		length2 = root2:len()
		if root2:sub(length2, length2) == root2:sub(length2-1, length2-1) then
			root3 = root2:sub(1, length2-1)
		else
			root3 = root2
		end
		if PAGENAME:find('[iouyæøå]$') then
			present_tense = PAGENAME .. 'r'
		else
			present_tense = root .. 'er'
		end
		if not root3:find('ng$') and not root3:find('r$') and not root:find('øym') then
			if root3:find('[aeiouyæøå]$') then
				past_tense = root3 .. 'dde'
				past_participle = link(PAGENAME, root3 .. 'dd') .. '/' .. link(PAGENAME, root3 .. 'tt')
			else
				past_tense = root3 .. 'de'
				past_participle = link(PAGENAME, root3 .. 'd') .. '/' .. link(PAGENAME, root3 .. 't')
			end
		else
			past_tense = root3 .. 'de'
			past_participle = root3 .. 't'
		end
		
		passive_infinitive = root .. 'ast'
		present_participle = root .. 'ande'
		imperative = root2_imp
	end
	
	if class == '4' then
		if root:sub(length-1, length-1) == root:sub(length-2, length-2) then
			root2 = root:sub(1, length-2)
			if root:sub(length-1, length-1) == 'n' then -- døm!, but kjenn!
				imperative = link(PAGENAME, root) 
			else
				imperative = link(PAGENAME, root2)
			end
		else
			root2 = root
			imperative = link(PAGENAME, root) 
		end
		present_tense = root .. 'er'
		past_tense = link(PAGENAME, root2 .. 'de') .. '/' .. link(PAGENAME, root2 .. 'te')
		past_participle = root2 .. 't'
		passive_infinitive = root .. 'ast'
		present_participle = root .. 'ande'
	end
	
	table.insert(data.inflections, {label = 'ကာလပစ္စုပ္ပန်', present_tense})
	table.insert(data.inflections, {label = 'ကာလအတိတ်', past_tense})
	table.insert(data.inflections, {label = 'လုပ်ကၠောန်လဝ်နူအတိတ်', past_participle})
	if not args['no_st'] then
		table.insert(data.inflections, {label = 'ဟၟဲတွဵုဒနက်ဟွံတဝ်စၞေဟ်', passive_infinitive})
	end
	if not args['no_prespart'] then
		table.insert(data.inflections, {label = 'ကြိယာပစ္စုပ္ပန်', present_participle})
	end
	if not args['no_imp'] then
		table.insert(data.inflections, {label = 'ဗွဲမပြဟ်', imperative})
	end
	
	return require("Module:headword").full_headword(data)
end
 
return export