This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

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

local accel_forms = {
	--NOUNS
	nsi = "nom|s",
	nsd = "def|nom|s",
	npi = "nom|p",
	npd = "def|nom|p",
	asi = "acc|s",
	asd = "def|acc|s",
	api = "acc|p",
	apd = "def|acc|p",
	dsi = "dat|s",
	dsd = "def|dat|s",
	dpi = "dat|p",
	dpd = "def|dat|p",
	gsi = "gen|s",
	gsd = "def|gen|s",
	gpi = "gen|p",
	gpd = "def|gen|p",
	
	--ADJECTIVES
	
	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
	-- Active

	-- No active infinitve is included since it is the lemma form.
	pres_part = "act|pres|part",
	past_part = "act|past|part",
	
	pres_ind_1sg = "1|s|pres|act|ind",
	pres_ind_2sg = "2|s|pres|act|ind",
	pres_ind_3sg = "3|s|pres|act|ind",
	pres_ind_1pl = "1|p|pres|act|ind",
	pres_ind_2pl = "2|p|pres|act|ind",
	pres_ind_3pl = "3|p|pres|act|ind",
	past_ind_1sg = "1|s|past|act|ind",
	past_ind_2sg = "2|s|past|act|ind",
	past_ind_3sg = "3|s|past|act|ind",
	past_ind_1pl = "1|p|past|act|ind",
	past_ind_2pl = "2|p|past|act|ind",
	past_ind_3pl = "3|p|past|act|ind",
	
	pres_sub_1sg = "1|s|pres|act|sub",
	pres_sub_2sg = "2|s|pres|act|sub",
	pres_sub_3sg = "3|s|pres|act|sub",
	pres_sub_1pl = "1|p|pres|act|sub",
	pres_sub_2pl = "2|p|pres|act|sub",
	pres_sub_3pl = "3|p|pres|act|sub",
	past_sub_1sg = "1|s|past|act|sub",
	past_sub_2sg = "2|s|past|act|sub",
	past_sub_3sg = "3|s|past|act|sub",
	past_sub_1pl = "1|p|past|act|sub",
	past_sub_2pl = "2|p|past|act|sub",
	past_sub_3pl = "3|p|past|act|sub",
	
	impr_2sg = "2|s|act|imp",
	impr_1pl = "1|p|act|imp",
	impr_2pl = "2|p|act|imp",
	
	-- Mediopassive
	
	mp_infinitive = "mp|inf",
	mp_pres_part = "mp|pres|part",
	mp_past_part = "mp|past|part",
	
	mp_pres_ind_1sg = "1|s|pres|mp|ind",
	mp_pres_ind_2sg = "2|s|pres|mp|ind",
	mp_pres_ind_3sg = "3|s|pres|mp|ind",
	mp_pres_ind_1pl = "1|p|pres|mp|ind",
	mp_pres_ind_2pl = "2|p|pres|mp|ind",
	mp_pres_ind_3pl = "3|p|pres|mp|ind",
	mp_past_ind_1sg = "1|s|past|mp|ind",
	mp_past_ind_2sg = "2|s|past|mp|ind",
	mp_past_ind_3sg = "3|s|past|mp|ind",
	mp_past_ind_1pl = "1|p|past|mp|ind",
	mp_past_ind_2pl = "2|p|past|mp|ind",
	mp_past_ind_3pl = "3|p|past|mp|ind",
	
	mp_pres_sub_1sg = "1|s|pres|mp|sub",
	mp_pres_sub_2sg = "2|s|pres|mp|sub",
	mp_pres_sub_3sg = "3|s|pres|mp|sub",
	mp_pres_sub_1pl = "1|p|pres|mp|sub",
	mp_pres_sub_2pl = "2|p|pres|mp|sub",
	mp_pres_sub_3pl = "3|p|pres|mp|sub",
	mp_past_sub_1sg = "1|s|past|mp|sub",
	mp_past_sub_2sg = "2|s|past|mp|sub",
	mp_past_sub_3sg = "3|s|past|mp|sub",
	mp_past_sub_1pl = "1|p|past|mp|sub",
	mp_past_sub_2pl = "2|p|past|mp|sub",
	mp_past_sub_3pl = "3|p|past|mp|sub",
	
	mp_impr_2sg = "2|s|mp|imp",
	mp_impr_1pl = "1|p|mp|imp",
	mp_impr_2pl = "2|p|mp|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