Module:nn-cell

From Wiktionary, the free dictionary
Jump to navigation Jump to search

local m_links = require("Module:links")
local lang = require("Module:languages").getByCode("nn")
local export = {}

local accel_forms = {
	--NOUNS
	nasi = "indef|s",
	nasd = "def|s",
	napi = "indef|p",
	napd = "def|p",
	dsi = "indef|dat|s",
	dsd = "def|dat|s",
	dpi = "indef|dat|p",
	dpd = "def|dat|p",
	gsi = "indef|gen|s",
	gsd = "def|gen|s",
	gpi = "indef|gen|p",
	gpd = "def|gen|p",
	
	--ADJECTIVES
	nasm = "m|s",
	nasf = "f|s",
	nasn = "n|s",
	
	napm = "m|p",
	napf = "f|p",
	napn = "n|p",
	
	comp = "comparative|",
	wk_sup = "weak|superlative|",
	
	nsm = "m|nom|s", --strong nom. sg.
	nsf = "f|nom|s",
	nsn = "n|nom|s",
	asm = "m|acc|s", --strong acc. sg.
	asf = "f|acc|s",
	asn = "n|acc|s",
	gsm = "m|gen|s", --strong gen. sg.
	gsf = "f|gen|s",
	gsn = "n|gen|s",
	dsm = "m|dat|s", --strong dat. sg.
	dsf = "f|dat|s",
	dsn = "n|dat|s",
	
	npm = "m|nom|p", --strong nom. pl.
	npf = "f|nom|p",
	npn = "n|nom|p",
	apm = "m|acc|p", --strong acc. pl.
	apf = "f|acc|p",
	apn = "n|acc|p",
	gp  = "m//f//n|gen|p", --strong gen. pl.
	dp  = "m//f//n|dat|p",
	
	--VERBS

	-- No active infinitve is included since it is the lemma form.
	pres_part = "pres|part",
	past_part = "m|past|part",
	
	sup = "sup",
	
	pres_sg = "pres",
	pres_pl = "p|pres",
	past_sg = "past",
	past_pl = "p|past",
	
	pres_sub = "pres|sub",
	past_sub = "past|sub",
	
	impr_sg = "s|imp",
	impr_pl = "p|imp"
	
}

local mode_prefix = { --this is prefixed to the index value in accel_forms
	mpass  = "mp_"
}

local mode_prepend = { --on the other hand, this is prefixed to the accelerated text itself
	wk      = "weak|",
	str     = "strong|",
	comp    = "comparative|",
	wk_sup  = "weak|superlative|",
	str_sup = "strong|superlative|"
}

function export.create(frame)
	local args = frame:getParent().args
	local links = {}
	if not args[1] or args[1] == "" then
		return "―"
	else
		local accel_form = args[2]
		local accel
		if accel_form then
			local mode = args[3]
			if mode and mode_prefix[mode] then
				accel_form = mode_prefix[mode] .. accel_form
			end
			if accel_forms[accel_form] then
				if mode and mode_prepend[mode] then
					accel_form = mode_prepend[mode] .. accel_forms[accel_form]
				else
					accel_form = accel_forms[accel_form]
				end
			end
			accel = {form = accel_form}
		end
		local words = mw.text.split(args[1], "%s*,%s*")
		if words then
			for i,j in ipairs(words) do
				table.insert(links, m_links.full_link({lang = lang, term = j, accel = accel}))
			end
		end
	end
	return table.concat(links, ", ")
end

return export