Module:nb-verb-reg

From Wiktionary, the free dictionary
Jump to navigation Jump to search
This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local lang = require('Module:languages').getByCode('nb')

local export = {}

function export.main(frame)
	local PAGENAME = mw.title.getCurrentTitle().text
	local args = frame:getParent().args
	local class = tonumber(frame.args[1])

	local root = PAGENAME:gsub('e$', '')
	arg1 = nil
	if args[1] ~= root then
		arg1 = args[1]
	end
	
	local data = {lang = lang, pos_category = 'verbs', categories = {}, inflections = {}}

	-- Generate inflected forms
	local presentTense = {label = 'present tense'}
	local pastTense = {label = 'past tense'}
	local pastParticiple = {label = 'past participle'}

	if class == 1 then
		table.insert(presentTense, root .. 'er')
		table.insert(pastTense, root .. 'a')
		table.insert(pastTense, root .. 'et')
		table.insert(pastParticiple, root .. 'a')
		table.insert(pastParticiple, root .. 'et')
	end
	if class == 2 then
		table.insert(presentTense, root .. 'er')
		table.insert(pastTense, (arg1 or root) .. 'te')
		table.insert(pastParticiple, (arg1 or root) .. 't')
	end
	if class == 3 then
		table.insert(presentTense, root .. 'er')
		table.insert(pastTense, (arg1 or root) .. 'de')
		table.insert(pastParticiple, (arg1 or root) .. 'd')
	end
	
	-- Add inflections
	table.insert(data.inflections, presentTense)
	table.insert(data.inflections, pastTense)
	table.insert(data.inflections, pastParticiple)
	
	return require('Module:headword').full_headword(data)
end

return export