Module:nn-verb-reg

Definition from Wiktionary, the free dictionary
Jump to: navigation, search
The following documentation is located at Module:nn-verb-reg/documentation. [edit]

{{documentation needed}]


local m_headword = require("Module:headword")
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 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 = PAGENAME .. '/[[' .. 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, PAGENAME) .. '/' .. 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(inflections, {label = 'present tense', present_tense})
	table.insert(inflections, {label = 'past tense', past_tense})
	table.insert(inflections, {label = 'past participle', past_participle})
	if not args['no_st'] then
		table.insert(inflections, {label = 'passive infinitve', passive_infinitive})
	end
	if not args['no_prespart'] then
		table.insert(inflections, {label = 'present participle', present_participle})
	end
	if not args['no_imp'] then
		table.insert(inflections, {label = 'imperative', imperative})
	end
 
	return
		m_headword.format_headword(PAGENAME, lang, nil) ..
		m_headword.format_inflections(inflections, lang, nil)
end
 
return export