Module:nn-noun-uncountable

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 export = {}

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

function export.main(frame)
	local word = mw.title.getCurrentTitle().text
	local g1, g2, g3 = frame.args[1], frame.args[2], frame.args[3]
	local args = frame:getParent().args
	local length = word:len()
	
	local root
	if args['root'] and args['root'] ~= '' then
		root = args['root']    
	elseif word:find('e$') then
		root = word:sub(1, length-1)
	else
		root = word
	end
	
	if args['root2'] and args['root2'] ~= '' then
		root2 = args['root2']
	end
	
	local data = {lang = lang, pos_category = "nouns", categories = {lang:getCanonicalName() .. " uncountable nouns"}, inflections = {}}
	
	if g3 and g3 ~= '' then
		data.genders = {g1, g2, g3}
	elseif g2 and g2 ~= '' then
		data.genders = {g1, g2}
	else
		data.genders = {g1}
	end
	
	suffix = {["m"] = 'en', ["f"] = 'a', ["n"] = 'et', ["?"] = '?'}
	
	local all_forms = { root .. suffix[g1] }
	if g2 and g2 ~= '' then
		table.insert(all_forms, root .. suffix[g2])
	end       
	if g3 and g3 ~= '' then
		table.insert(all_forms, root .. suffix[g3])
	end
	if root2 and root2 ~= '' then
		table.insert(all_forms, root2 .. suffix[g1])
	end	
	
	all_forms.label = 'definite singular'
	
	table.insert(data.inflections, all_forms)
	table.insert(data.inflections, { label = '[[Appendix:Glossary#uncountable|uncountable]]' })

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