Jump to content

Module:nn-noun-reg

ពីWiktionary

Documentation for this module may be created at Module:nn-noun-reg/doc

local export = {}
local m_headword = require("Module:headword")

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

function export.link(form)
	error("Deprecated function")
end

function export.main(frame)
	local args = frame:getParent().args
	local PAGENAME = mw.title.getCurrentTitle().text
	
	local class = frame.args[1]
	
	local length = PAGENAME:len()
	local root = PAGENAME:gsub("e$", "")
	local root_pl = args[1]; if root_pl == "" then root_pl = nil end
	
	if args['stem'] then
		root = args['stem']
		root_pl = root
	end
	
	if not root_pl then
		if PAGENAME:find("kel$") then
			root_pl = PAGENAME:gsub("k?kel$", "kl")
		elseif PAGENAME:find("tel$") and not PAGENAME:find('mittel$') and not PAGENAME:find('pitel$')then
			root_pl = PAGENAME:gsub("t?tel$", "tl")
		else
			root_pl = root
		end
	end
	
	gender = class:sub(1, 1) -- extracts e.g. "m" from "m1"
	
	if class == 'm1' then
		definite_singular = root .. 'en'
		indefinite_plural = root_pl .. 'ar'
		definite_plural = root_pl .. 'ane'
	elseif class == 'm2' then
		definite_singular = root .. 'en'
		indefinite_plural = "[[" .. root_pl .. 'er' .. ']]/[[' .. root_pl .. 'ar' .. "]]"
		definite_plural = "[[" .. root_pl .. 'ene' .. ']]/[[' .. root_pl .. 'ane' .. "]]"
	elseif class == 'm3' then
		definite_singular = root .. 'en'
		indefinite_plural = root
		definite_plural = "[[" .. root_pl .. 'a' .. ']]'
	elseif class == 'f1' or class == 'f2' then
		definite_singular = root .. 'a'
		indefinite_plural = root_pl .. 'er'
		definite_plural = root_pl .. 'ene'
	elseif class == 'f3' then
		definite_singular = root .. 'a'
		indefinite_plural = root_pl .. 'ar'
		definite_plural = root_pl .. 'ane'
	elseif class == 'n1' then
		if args[1] and args[1] ~= '' then
			root = args[1]
			root_pl = args[1]
		end
		definite_singular = root .. 'et'
		indefinite_plural = PAGENAME
		definite_plural = root_pl .. 'a'
	elseif class == '-ium' then
		root = PAGENAME:gsub('um$', '')
		definite_singular = root .. 'et'
		indefinite_plural = PAGENAME
		definite_plural = root .. 'a'
		gender = 'n'
	end    
	
	local inflections = { {label = "ឯកវចនៈច្បាស់លាស់", definite_singular} }
	
	if indefinite_plural then
		table.insert(inflections, {label = "ពហុវចនៈមិនច្បាស់លាស់", indefinite_plural})
	end
	if definite_plural then
		table.insert(inflections, {label = "ពហុវចនៈច្បាស់លាស់", definite_plural})
	end
	
	if args['gen_dsg'] then
		table.insert(inflections, { label = "genitive definite singular", args['gen_dsg'] })
	end
	
	return
		m_headword.format_headword(PAGENAME, lang, "Latn") ..
		m_headword.format_genders({gender}, lang) ..
		m_headword.format_inflections(inflections, lang, "Latn")
end

return export