Hopp til innhald

Modul:irregulært nynorsk eigenskapsord

Frå Wiktionary - den frie ordboka

Dokumentasjon for modulen kan opprettast på Modul:irregulært nynorsk eigenskapsord/dok

local export = {}

local lang = require("Module:languages").getByCode("nn")
 
function export.main(frame)
	local args = frame:getParent().args
	local PAGENAME = mw.title.getCurrentTitle().text
	local meir = not not (args['meir'] or args['more'])

	local masculine = args['mfn']  or args['fmn'] or args['mf'] or args['fm'] or args['m'] or args['hankjønn'] or PAGENAME
	local feminine = args['mfn'] or args['fmn'] or args['mf'] or args['fm'] or args['f'] or args['hokjønn'] or PAGENAME
	local neuter = args['mfn'] or args['fmn'] or args['n'] or args['inkjekjønn'] or PAGENAME .. 't'
	local definite_singular = args['ds_pl'] or args['bu_ein'] or args['ds'] or args['bunde_eintal'] or PAGENAME .. 'e'
	local plural = args['ds_pl'] or args['pl'] or args['fleirtal'] or PAGENAME .. 'e'
	
	local data = {lang = lang, pos_category = "eigenskapsord", categories = {}, inflections = {}}
	
	if masculine == feminine == neuter and masculine ~= '-' then
		table.insert(data.inflections, { label = 'ubunde eintal', masculine })
	elseif masculine == feminine and masculine  ~= '-' then
		table.insert(data.inflections, { label = 'hankjønn og hokjønn', masculine })
		table.insert(data.inflections, { label = 'inkjekjønn', neuter })
	else
		if masculine ~= '-' then
			table.insert(data.inflections, {label = 'hankjønn', masculine})
		end
		if feminine ~= '-' then
			table.insert(data.inflections, {label = 'hokjønn', feminine})
		end
		if neuter ~= '-' then
			table.insert(data.inflections, {label = 'inkjekjønn', neuter})
		end
	end
	
	if definite_singular == plural then
		if args['ds_pl2'] then
			local definite_singular2 = args['ds_pl2']
			definite_singular = '[[' .. definite_singular .. ']]/[[' .. definite_singular2 .. ']]'
		end
		if plural ~= '-' then
			table.insert(data.inflections, {label = 'bunde eintal og fleirtal', definite_singular})
		end
	else
		if args['ds2'] then
			local definite_singular2 = args['ds2']
			definite_singular = '[[' .. definite_singular .. ']]/[[' .. definite_singular2 .. ']]'
		end
		if args['ds3'] then
			local definite_singular3 = args['ds3']
			definite_singular = definite_singular .. '/[[' .. definite_singular3 .. ']]'
		end
		if args['pl2'] then
			local plural2 = args['pl2']
			plural = '[[' .. plural .. ']]/[[' .. plural2 .. ']]'
		end
		
		if definite_singular ~= '-' then
			table.insert(data.inflections, {label = 'bunde eintal', definite_singular})
		end
		if plural ~= '-' then
			table.insert(data.inflections, {label = 'fleirtal', plural})
		end
	end
	
	if not meir then
		local comparative = args['komp'] or args['comp'] or args['komparativ'] or args['komparativ'] or PAGENAME .. 'are'
		if args['komp2'] or args['comp2'] or args['komparativ2'] or args['comparative2'] then
			local comparative2 = args['komp2'] or args['comp2'] or args['komparativ2'] or args['comparative2']
			comparative = '[[' .. comparative .. ']]/[[' .. comparative2 .. ']]'
		end 

		local indefinite_superlative = args['sup_ub'] or args['sup_indef'] or PAGENAME .. 'ast'
		if args['sup_ub2'] or args['sup_indef2'] then
			local indefinite_superlative2 = args['sup_ub2'] or args['sup_indef2']
			indefinite_superlative = '[[' .. indefinite_superlative .. ']]/[[' .. indefinite_superlative2 .. ']]'
		end 

		local definite_superlative = args['sup_bu'] or args['sup_indef'] or PAGENAME .. 'aste'
		if args['sup_bu2'] or args['sup_indef2'] then
			local definite_superlative2 = args['sup_bu2'] or args['sup_indef2']
			definite_superlative = '[[' .. definite_superlative .. ']]/[[' .. definite_superlative2 .. ']]'
		end

		if args['sup'] or args['superlativ'] or args['superlativ'] then
			indefinite_superlative = args['sup'] or args['superlativ'] or args['superlativ']
			definite_superlative = indefinite_superlative .. 'e'
		end
		
		if args['sup2'] or args['superlativ2'] or args['superlative2'] then
			indefinite_superlative2 = args['sup2'] or args['superlativ2'] or args['superlative2']
			indefinite_superlative = '[[' .. indefinite_superlative .. ']]/[[' .. indefinite_superlative2 .. ']]'
				
			definite_superlative2 = indefinite_superlative2 .. 'e'
			definite_superlative = '[[' .. definite_superlative .. ']]/[[' .. definite_superlative2 .. ']]'
		end

		if comparative then
			table.insert(data.inflections, {label = 'komparativ', comparative})
		end
		if indefinite_superlative then
			table.insert(data.inflections, {label = 'ubunden superlativ', indefinite_superlative})
		end
		if definite_superlative then
			table.insert(data.inflections, {label = 'bunden superlativ', definite_superlative})
		end
	elseif meir then
		table.insert(data.inflections, { label = 'komparativ', '[[meir]] ' .. PAGENAME })
		table.insert(data.inflections, { label = 'superlativ', '[[mest]] ' .. PAGENAME })	
	end

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

return export