Modul:nn-noun-uncountable

Daripada Wiktionary
Jump to navigation Jump to search

Pendokumenan untuk modul ini boleh diciptakan di Modul:nn-noun-uncountable/doc

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 = "kata nama", categories = {"Kata nama tidak berbilang bahasa " .. lang:getCanonicalName()}, 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 = 'mufrad pasti'
	
	table.insert(data.inflections, all_forms)
	table.insert(data.inflections, { label = '[[Wiktionary:Lampiran glosari#tidak berbilang|tidak berbilang]]' })

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