Module:nn-adj-reg

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

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

function export.main(frame)
	local word = mw.title.getCurrentTitle().text
	local args = frame:getParent().args
	local class = frame.args[1]  
	local length = word:len()
	
	local data = {lang = lang, pos_category = "adjectives", categories = {}, inflections = {}}
	
	local root = word
	local root2 = word
	
	if class == '1' then
		local root_n = mw.ustring.gsub(word, "kk$", "k")
		table.insert(data.inflections, { label = 'neuter', root_n .. 't' })
		table.insert(data.inflections, { label = 'definite singular and plural', root .. 'e' })
	elseif class == '2' then
		table.insert(data.inflections, { label = 'indefinite singular', word })
		table.insert(data.inflections, { label = 'definite singular and plural', root .. 'e' })
	elseif class == '3' then
		table.insert(data.inflections, { label = 'singular and plural', word })
	elseif class == '4' then
		root = word:sub(1, length-2)
		root2 = root .. 'n'

		table.insert(data.inflections, {label = 'neuter', root .. 'e',  root .. 'ent'})
		table.insert(data.inflections, {label = 'definite singular and plural', root .. 'ne'})
	elseif class == '4_2012' then
		root = word:sub(1, length-2)
		root2 = root .. 'n'

		table.insert(data.inflections, {label = 'feminine', word, root .. 'i'})
		table.insert(data.inflections, {label = 'neuter', root .. 'e',  root .. 'i',  root .. 'ent'})
		table.insert(data.inflections, {label = 'definite singular and plural', root .. 'ne'})
	elseif class == '5' then
		root = word:sub(1, length-2)
		
		if word:sub(-2) == 'en' then -- e.g. 'rettkomen'
			root2 = root .. 'n' -- for the superlatives
			table.insert(data.inflections, {label = 'neuter', root .. 'e'})
			local root_dsg_pl = mw.ustring.gsub(root, "(.)%1$", "%1") -- rettkoMne (of [[rettkommen]])
			table.insert(data.inflections, {label = 'definite singular and plural', root_dsg_pl .. 'ne'})
		else
			root2 = word:sub(1, length-2) .. word:sub(-1)
			table.insert(data.inflections, {label = 'neuter', word .. 't'})
			table.insert(data.inflections, {label = 'definite singular and plural', root2 .. 'e'})
		end
	end
	
	if args[1] == 'meir' or args[1] == 'more' or class == '3' then
		meir = true
	end
	
	if args[1] == 'non-comparable' or args[1] == 'non-comp' then
		meir = false
		non_comp = true
	end
	
	if meir then
		table.insert(data.inflections, { label = 'comparative', '[[meir]] ' .. word })
		table.insert(data.inflections, { label = 'superlative', '[[mest]] ' .. word })
	elseif not non_comp then
		table.insert(data.inflections, { label = 'comparative', root2 .. 'are' })
		table.insert(data.inflections, { label = 'indefinite superlative', root2 .. 'ast' })
		table.insert(data.inflections, { label = 'definite superlative', root2 .. 'aste' })
	end

	return require('Module:headword').full_headword(data)
end
 
return export