Module:et-nominals

Hello, you have come here looking for the meaning of the word Module:et-nominals. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:et-nominals, but we will also tell you about its etymology, its characteristics and you will know how to say Module:et-nominals in singular and plural. Everything you need to know about the word Module:et-nominals you have here. The definition of the word Module:et-nominals will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:et-nominals, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module is used for inflecting Estonian nominals.


local m_utilities = require("Module:utilities")
local m_links = require("Module:links")

local export = {}

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

-- Functions that do the actual inflecting by creating the forms of a basic term.
local inflections = {}

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local infl_type = frame.args or error("Inflection type has not been specified. Please pass parameter 1 to the module invocation")
	local args = frame:getParent().args
	
	if not inflections then
		error("Unknown inflection type '" .. infl_type .. "'")
	end
	
	local data = {forms = {}, title = nil, categories = {}}
	
	-- Generate the forms
	inflections(args, data)
	
	-- Postprocess
	postprocess(args, data)
	
	if args then
		table.insert(data.categories, "et-decl with nosg")
	end
	
	if args then
		table.insert(data.categories, "et-decl with nopl")
	end
	
	if args then
		table.insert(data.categories, "et-decl with type")
	end
	
	return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end

function get_params(args, num, gradation)
	local params = {}
	
	params.base = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{1}}}"); if not params.base or params.base == "" then error("Parameter 1 (base stem) may not be empty.") end
	
	if gradation then
		if num == 5 then
			params.strong = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{2}}}") or ""
			params.weak = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{3}}}") or ""
			params.final = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{4}}}"); if not params.final or params.final == "" then error("Parameter 4 (final letter(s)) may not be empty.") end
			params.final_nom_sg = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{5}}}") or ""
		elseif num == 4 then
			params.strong = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{2}}}") or ""
			params.weak = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{3}}}") or ""
			params.final = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{4}}}"); if not params.final or params.final == "" then error("Parameter 4 (final letter(s)) may not be empty.") end
		elseif num == 3 then
			params.strong = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{2}}}") or ""
			params.weak = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{3}}}") or ""
		end
	else
		if num == 3 then
			params.final = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{2}}}"); if not params.final or params.final == "" then error("Parameter 2 (final letter(s)) may not be empty.") end
			params.final_nom_sg = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{3}}}") or ""
		elseif num == 2 then
			params.final = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{2}}}") or ""
		end
	end
	
	return params	
end


--[=[
	Inflection functions
]=]--

local stem_endings = {}

stem_endings = {
	 = "",
}

stem_endings = {
	      = "",
	 = "sse",
	      = "s",
	      = "st",
	      = "le",
	      = "l",
	      = "lt",
	      = "ks",
	      = "ni",
	      = "na",
	      = "ta",
	      = "ga",
	      = "d",
}

stem_endings = {
	 = "",
}

stem_endings = {
	 = "",
}

stem_endings = {
	      = "",
	 = "sse",
	 = "s",
	 = "st",
	 = "le",
	 = "l",
	 = "lt",
	 = "ks",
	      = "ni",
	      = "na",
	      = "ta",
	      = "ga",
}

stem_endings = {
	 = "sse",
	 = "s",
	 = "st",
	 = "le",
	 = "l",
	 = "lt",
	 = "ks",
}

stem_endings = {
	 = "",
}


-- Create forms based on each stem, by adding endings to it
local function process_stems(data, stems)
	-- Go through each of the stems given
	for stem_key, substems in pairs(stems) do
		for _, stem in ipairs(substems) do
			-- Attach the endings to the stem
			for form_key, ending in pairs(stem_endings) do
				if not data.forms then
					data.forms = {}
				end
				
				table.insert(data.forms, stem .. ending)
			end
		end
	end
end


inflections = function(args, data)
	data.title = "ÕS type "
	table.insert(data.categories, lang:getCanonicalName() .. " ohutu-type nominals")
	
	local params = get_params(args, 1)
	local i_stem = mw.ustring.gsub(params.base, "i$", "e")
	
	if mw.ustring.find(params.base, "i$") then
		data.title = data.title .. "], no gradation"
	else
		data.title = data.title .. "], no gradation"
	end
	
	local stems = {}
	stems       = {params.base}
	stems           = {params.base}
	stems       = {params.base .. "t"}
	stems = nil
	stems      = {params.base .. "te"}
	stems     = {i_stem .. "i"}
	stems       = {i_stem .. "id"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " õpik-type nominals")
	
	local params = get_params(args, 3)
	local i_stem = mw.ustring.gsub(params.base .. params.final, "i$", "e")
	
	local stems = {}
	stems       = {params.base .. params.final_nom_sg}
	stems           = {params.base .. params.final}
	stems       = {params.base .. params.final .. "t"}
	stems = nil
	stems      = {params.base .. params.final .. "te"}
	stems     = {i_stem .. "i"}
	stems       = {i_stem .. "id"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " vaher-type nominals")
	
	local params = get_params(args, 5, true)
	local i_stem = mw.ustring.gsub(params.base .. params.strong .. params.final, "i$", "e")
	
	if params.strong == params.weak or params.strong == params.weak .. params.weak then
		data.title = data.title .. ", length gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end
	
	local stems = {}
	stems       = {params.base .. params.weak .. params.final_nom_sg}
	stems           = {params.base .. params.strong .. params.final}
	stems       = {params.base .. params.strong .. params.final .. "t"}
	stems = nil
	stems      = {params.base .. params.strong .. params.final .. "te"}
	stems     = {i_stem .. "i"}
	stems       = {i_stem .. "id"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " ase-type nominals")
	
	local params = get_params(args, 2)
	
	local stems = {}
	stems       = {params.base}
	stems           = {params.base .. "me"}
	stems       = {params.base .. params.final}
	stems = nil
	stems      = {params.base .. "mete"}
	stems     = {params.base .. "mei"}
	stems       = {params.base .. "meid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " liige-type nominals")
	
	local params = get_params(args, 5, true)
	local i_stem = mw.ustring.gsub(params.base .. params.strong .. params.final, "i$", "e")
	
	if params.strong == params.weak or params.strong == params.weak .. params.weak then
		data.title = data.title .. ", length gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end
	
	local stems = {}
	stems       = {params.base .. params.weak .. params.final_nom_sg}
	stems           = {params.base .. params.strong .. params.final}
	stems       = {params.base .. params.weak .. params.final_nom_sg .. "t"}
	stems = nil
	stems      = {params.base .. params.strong .. params.final .. "te"}
	stems     = {i_stem .. "i"}
	stems       = {i_stem .. "id"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " mõte-type nominals")
	
	local params = get_params(args, 4, true)
	
	if params.strong == params.weak or params.strong == params.weak .. params.weak then
		data.title = data.title .. ", length gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end
	
	local stems = {}
	stems       = {params.base .. params.weak .. params.final}
	stems           = {params.base .. params.strong .. params.final}
	stems       = {params.base .. params.weak .. params.final .. "t"}
	stems = nil
	stems      = {params.base .. params.weak .. params.final .. "te"}
	stems     = {params.base .. params.strong .. params.final .. "i"}
	stems       = {params.base .. params.strong .. params.final .. "id"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " kallas-type nominals")
	
	local params = get_params(args, 5, true)
	local i_stem = mw.ustring.gsub(params.base .. params.strong .. params.final, "i$", "e")
	
	if params.strong == params.weak or params.strong == params.weak .. params.weak then
		data.title = data.title .. ", length gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end
	
	local stems = {}
	stems       = {params.base .. params.weak .. params.final_nom_sg}
	stems           = {params.base .. params.strong .. params.final}
	stems       = {params.base .. params.weak .. params.final_nom_sg .. "t"}
	stems = nil
	stems      = {params.base .. params.weak .. params.final_nom_sg .. "te"}
	stems     = {i_stem .. "i"}
	stems       = {i_stem .. "id"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " küünal-type nominals")
	
	local params = get_params(args, 5, true)
	
	if params.strong == params.weak or params.strong == params.weak .. params.weak then
		data.title = data.title .. ", length gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end
	
	local stems = {}
	stems       = {params.base .. params.weak .. params.final_nom_sg}
	stems           = {params.base .. params.strong .. params.final}
	stems       = {params.base .. params.weak .. params.final_nom_sg .. "t"}
	stems = nil
	stems      = {params.base .. params.weak .. params.final_nom_sg .. "de"}
	stems     = {params.base .. params.strong .. params.final .. "i"}
	stems       = {params.base .. params.strong .. params.final .. "id"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " katus-type nominals")
	
	local params = get_params(args, 1)
	
	local stems = {}
	stems       = {params.base .. "s"}
	stems           = {params.base .. "se"}
	stems       = {params.base .. "st"}
	stems = nil
	stems      = {params.base .. "ste"}
	stems     = {params.base .. "sei"}
	stems       = {params.base .. "seid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " soolane-type nominals")
	
	local params = get_params(args, 2)
	
	local stems = {}
	stems       = {params.base .. params.final}
	stems           = {params.base .. "se"}
	stems       = {params.base .. "st"}
	stems = nil
	stems      = {params.base .. "ste"}
	stems     = {params.base .. "sei"}
	stems       = {params.base .. "seid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " harjutus-type nominals")
	
	local params = get_params(args, 1)
	
	local stems = {}
	stems       = {params.base .. "s"}
	stems           = {params.base .. "se"}
	stems       = {params.base .. "st"}
	stems = {params.base .. "sse"}
	stems      = {params.base .. "ste"}
	stems     = {params.base .. "si"}
	stems       = {params.base .. "si"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " oluline-type nominals")
	
	local params = get_params(args, 2)
	
	local stems = {}
	stems       = {params.base .. params.final}
	stems           = {params.base .. "se"}
	stems       = {params.base .. "st"}
	stems = {params.base .. "sse"}
	stems      = {params.base .. "ste"}
	stems     = {params.base .. "si"}
	stems       = {params.base .. "si"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], length gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " suur-type nominals")
	
	local params = get_params(args, 1)
	local weak_stem = params.base
	local par_stem = params.base
	local ill_sg_stem = params.base .."de"
	local pl_stem = params.base
	
	if mw.ustring.find(params.base, "m$") then 
		par_stem = mw.ustring.gsub(params.base, "m$", "n")
		ill_sg_stem = mw.ustring.gsub(params.base, "m$", "n")
		pl_stem = mw.ustring.gsub(params.base, "m$", "n")
	end
	
	if mw.ustring.find(params.base, "mees$") then 
		ill_sg_stem = nil
		weak_stem = mw.ustring.gsub(params.base, "es$", "h")
	end
	
	local stems = {}
	stems       = {params.base}
	stems           = {weak_stem .. "e"}
	stems       = {par_stem .. "t"}
	stems = {ill_sg_stem}
	stems      = {pl_stem .. "te"}
	stems     = {weak_stem .. "i"}
	stems       = {weak_stem .. "i"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " uus-type nominals")
	
	local params = get_params(args, 2)
	local s_stem = mw.ustring.gsub(params.base .. params.final, "n$", "")
	local t_stem = params.base .. params.final
	
	if params.final ~= "" then
		data.title = data.title .. ", ''" .. params.final .. "d/" .. params.final .. "t-" .. params.final .. params.final .. "-" .. params.final .. "s'' gradation"
	else
		data.title = data.title .. ", ''d/t-ø-s'' gradation"
	end
	
	if mw.ustring.find(t_stem, "()s$") then
		s_stem = mw.ustring.gsub(params.base, "s$", "")
		
		local consonant = mw.ustring.match(t_stem, "()")
		t_stem = mw.ustring.gsub(t_stem, consonant .. "s$", "s")
	end
	
	local stems = {}
	stems       = {s_stem .. "s"}
	stems           = {params.base .. params.final .. params.final .. "e"}
	stems       = {t_stem .. "t"}
	stems = {params.base .. params.final .. "de"}
	stems      = {t_stem .. "te"}
	stems     = {s_stem .. "si"}
	stems       = {s_stem .. "si"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], ''d/t-ø-s'' gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " käsi-type nominals")
	
	local params = get_params(args, 1)
	local weak_stem = params.base
	
	if mw.ustring.find(params.base, "u$") then
		-- susi
		weak_stem = mw.ustring.gsub(params.base, "u$", "o")
	elseif mw.ustring.find(params.base, "ü$") then
		-- süsi
		weak_stem = mw.ustring.gsub(params.base, "ü$", "ö")
	end
	
	local stems = {}
	stems       = {params.base .. "si"}
	stems           = {weak_stem .. "e"}
	stems       = {params.base .. "tt"}
	stems = {params.base .. "tte"}
	stems      = {params.base .. "te"}
	stems     = {params.base .. "si"}
	stems       = {params.base .. "si"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " pere-type nominals")
	
	local params = get_params(args, 1)
	local ill_sg_stem = params.base
	
	if mw.ustring.find(ill_sg_stem, "$") or mw.ustring.find(ill_sg_stem, "^$") then
		ill_sg_stem = mw.ustring.gsub(ill_sg_stem, "(.)(.)$", "%1%1%2")
		else ill_sg_stem = nil
	end
	
	local stems = {}
	stems       = {params.base}
	stems           = {params.base}
	stems       = {params.base .. "t"}
	stems = {ill_sg_stem}
	stems      = {params.base .. "de"}
	stems     = {}
	stems       = {params.base .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " elu-type nominals")
	
	local params = get_params(args, 1)
	local ill_sg_stem = params.base
	
	if mw.ustring.find(ill_sg_stem, "$") or mw.ustring.find(ill_sg_stem, "^$") then
		local base, cons, vowel = mw.ustring.match(ill_sg_stem, "^(.-)(.)(.)$")
		
		if cons == "b" then
			ill_sg_stem = base .. "pp" .. vowel
		elseif cons == "d" then
			ill_sg_stem = base .. "tt" .. vowel
		elseif cons == "g" then
			ill_sg_stem = base .. "kk" .. vowel
		elseif cons == "v" then
			ill_sg_stem = nil
		elseif cons == "" then
			ill_sg_stem = nil
		else
			ill_sg_stem = base .. cons .. cons .. vowel
		end
	end
	
	local stems = {}
	stems       = {params.base}
	stems           = {params.base}
	stems       = {params.base}
	stems = {ill_sg_stem}
	stems      = {params.base .. "de"}
	stems     = {}
	stems       = {params.base .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " kivi-type nominals")
	
	local params = get_params(args, 1)
	local pl_stem = mw.ustring.gsub(params.base, "$", "e")
	local ill_sg_stem = params.base
	
	if mw.ustring.find(ill_sg_stem, "$") or mw.ustring.find(ill_sg_stem, "^$") then
		ill_sg_stem = mw.ustring.gsub(ill_sg_stem, "(.)(.)$", "%1%1%2")
	end
	
	local stems = {}
	stems       = {params.base}
	stems           = {params.base}
	stems       = {params.base}
	stems = {ill_sg_stem}
	stems      = {params.base .. "de"}
	stems     = {pl_stem}
	stems       = {pl_stem, params.base .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " pesa-type nominals")
	
	local params = get_params(args, 1)
	local pl_stem = mw.ustring.gsub(params.base, "$", "i")
	local ill_sg_stem = params.base
	
	if mw.ustring.find(ill_sg_stem, "$") or mw.ustring.find(ill_sg_stem, "^$") then
		ill_sg_stem = mw.ustring.gsub(ill_sg_stem, "(.)(.)$", "%1%1%2")
	end
	
	local stems = {}
	stems       = {params.base}
	stems           = {params.base}
	stems       = {params.base}
	stems = {ill_sg_stem}
	stems      = {params.base .. "de"}
	stems     = {pl_stem}
	stems       = {pl_stem, params.base .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " sõna-type nominals")
	
	local params = get_params(args, 1)
	local pl_stem = mw.ustring.gsub(params.base, "$", "u")
	local ill_sg_stem = params.base
	
	if mw.ustring.find(ill_sg_stem, "$") or mw.ustring.find(ill_sg_stem, "^$") then
		local base, cons, vowel = mw.ustring.match(ill_sg_stem, "^(.-)(.)(.)$")
		
		if cons == "b" then
			ill_sg_stem = base .. "pp" .. vowel
		else
			ill_sg_stem = base .. cons .. cons .. vowel
		end
	end
	
	local stems = {}
	stems       = {params.base}
	stems           = {params.base}
	stems       = {params.base}
	stems = {ill_sg_stem}
	stems      = {params.base .. "de"}
	stems     = {pl_stem}
	stems       = {pl_stem, params.base .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " nägu-type nominals")
	
	local params = get_params(args, 4, true)
	
	if params.strong == params.weak then
		data.title = data.title .. ", no gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end
	
	local extra_strong = params.strong
	local weak_stem = params.base .. params.weak .. params.final
	
	if params.strong == "b" then
		extra_strong = "pp"
	elseif params.strong == "d" then
		extra_strong = "tt"
	elseif params.strong == "g" then
		extra_strong = "kk"
	end
	
	if params.weak == "" then
		if mw.ustring.find(params.base, "ä$") and params.final == "u" then
			-- nägu
			weak_stem = params.base .. "o"
		elseif mw.ustring.find(params.base, "a$") and params.final == "u" then
			-- madu
			weak_stem = params.base .. "o"
		end
	end
	
	local stems = {}
	stems       = {params.base .. params.strong .. params.final}
	stems           = {weak_stem}
	stems       = {params.base .. params.strong .. params.final}
	stems = {params.base .. extra_strong .. params.final}
	stems      = {params.base .. params.strong .. params.final .. "de"}
	stems     = {}
	stems       = {params.base .. params.strong .. params.final .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " tuba-type nominals")
	
	local params = get_params(args, 4, true)
	
	if params.strong == params.weak then
		data.title = data.title .. ", no gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end
	
	local extra_strong = params.strong
	local weak_stem = params.base .. params.weak .. params.final
	
	if params.strong == "b" then
		extra_strong = "pp"
	elseif params.strong == "d" then
		extra_strong = "tt"
	elseif params.strong == "g" then
		extra_strong = "kk"
	end
	
	if params.weak == "" then
		if mw.ustring.find(params.base, "u$") then
			-- tuba
			if params.final == "a" then
				weak_stem = mw.ustring.gsub(params.base, "u$", "o") .. params.final
			end
		end
	end
	
	local stems = {}
	stems       = {params.base .. params.strong .. params.final}
	stems           = {weak_stem}
	stems       = {params.base .. params.strong .. params.final}
	stems = {params.base .. extra_strong .. params.final}
	stems      = {params.base .. params.strong .. params.final .. "de"}
	stems     = {}
	stems       = {params.base .. params.strong .. "e", params.base .. params.strong .. params.final .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " sõda-type nominals")
	
	local params = get_params(args, 4, true)
	
	if params.strong == params.weak then
		data.title = data.title .. ", no gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end
	
	local extra_strong = params.strong
	local weak_stem = params.base .. params.weak .. params.final
	local weak_pl_stem = params.base .. params.weak .. "u"
	
	if params.strong == "b" then
		extra_strong = "pp"
	elseif params.strong == "d" then
		extra_strong = "tt"
	elseif params.strong == "g" then
		extra_strong = "kk"
	end
	
	if params.weak == "" then
		if mw.ustring.find(params.base, "i$") then
			-- rida
			if params.final == "a" then
				weak_stem = mw.ustring.gsub(params.base, "i$", "e") .. params.final
			end
			
			weak_pl_stem = nil
		end
	end
	
	local stems = {}
	stems       = {params.base .. params.strong .. params.final}
	stems           = {weak_stem}
	stems       = {params.base .. params.strong .. params.final}
	stems = {params.base .. extra_strong .. params.final}
	stems      = {params.base .. params.strong .. params.final .. "de"}
	stems     = {weak_pl_stem}
	stems       = {params.base .. params.strong .. "u", params.base .. params.strong .. params.final .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " seminar-type nominals")
	
	local params = get_params(args, 1)
	
	local stems = {}
	stems       = {params.base}
	stems           = {params.base .. "i"}
	stems       = {params.base .. "i"}
	stems = {params.base .. "i"}
	stems      = {params.base .. "ide"}
	stems     = {params.base .. "e"}
	stems       = {params.base .. "e", params.base .. "isid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " süli-type nominals")
	
	local params = get_params(args, 1)
	local ill_sg_stem = params.base
	
	if mw.ustring.find(ill_sg_stem, "$") or mw.ustring.find(ill_sg_stem, "^$") then
		local base, cons = mw.ustring.match(ill_sg_stem, "^(.-)(.)$")
		ill_sg_stem = base .. cons .. cons
	end
	
	local stems = {}
	stems       = {params.base .. "i"}
	stems           = {params.base .. "e"}
	stems       = {params.base .. "e"}
	stems = {ill_sg_stem .. "e"}
	stems      = {params.base  .. "ede"}
	stems     = {}
	stems       = {params.base .. "esid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " meri-type nominals")
	
	local params = get_params(args, 1)
	local ill_sg_stem = params.base
	local par_t = "d"
	local par_stem = params.base .. par_t
	
	if mw.ustring.find(params.base, "m$") then 
		par_stem = mw.ustring.gsub(params.base, "m$", "n") .. par_t
	end
	
	if mw.ustring.find(ill_sg_stem, "$") or mw.ustring.find(ill_sg_stem, "^$") then
		local base, cons = mw.ustring.match(ill_sg_stem, "^(.-)(.)$")
		ill_sg_stem = base .. cons .. cons
	end
	
	if mw.ustring.find(params.base, "$") then 
		par_t = "t" -- kusi
		else par_t = "d"
	end	
	
	local stems = {}
	stems       = {params.base .. "i"}
	stems           = {params.base .. "e"}
	stems       = {par_stem}
	stems = {ill_sg_stem .. "e"}
	stems      = {params.base  .. "ede"}
	stems     = {}
	stems       = {params.base .. "esid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " jõgi-type nominals")
	
	local params = get_params(args, 3, true)
	local extra_strong = params.strong
	
	if params.strong == "g" then
		extra_strong = "kk"
	end
	
	if params.strong == params.weak or params.strong == params.weak .. params.weak then
		data.title = data.title .. ", length gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end
	
	local stems = {}
	stems       = {params.base .. params.strong .. "i"}
	stems           = {params.base .. params.weak .. "e"}
	stems       = {params.base .. params.strong .. "e"}
	stems = {params.base .. extra_strong .. "e"}
	stems      = {params.base .. params.strong .. "ede"}
	stems     = {}
	stems       = {params.base .. params.strong .. "esid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " põu-type nominals")
	
	local params = get_params(args, 4, true)
	
	if params.strong == params.weak or params.strong == params.weak .. params.weak then
		data.title = data.title .. ", length gradation"
	elseif mw.ustring.find(params.base, "ks$") then
		data.title = data.title .. ", irregular gradation"
	end
	
	local stems = {}
	stems       = {params.base}
	stems           = {params.weak .. params.final}
	stems       = {params.strong .. params.final}
	stems = {params.strong .. params.final}
	stems      = {params.strong .. params.final .. "de"}
	stems     = {}
	stems       = {params.strong .. params.final .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " riik-type nominals")
	
	local params = get_params(args, 4, true)
	local weak_stem = params.base .. params.weak .. params.final
	local pl_short_stem = params.base .. params.weak .. "e"
	
	if params.strong == params.weak or params.strong == params.weak .. params.weak then
		data.title = data.title .. ", length gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end
	
	if mw.ustring.find(params.base, "$") and params.final == "u" and params.weak == "" then 
		weak_stem = params.base .. params.weak
	end

	if params.weak == "" and mw.ustring.match(params.base, "()()$") then
		pl_short_stem = nil
	else
		pl_short_stem = pl_short_stem
	end
	
	local stems = {}
	stems       = {params.base .. params.strong}
	stems           = {weak_stem}
	stems       = {params.base .. params.strong .. params.final}
	stems = {params.base .. params.strong .. params.final}
	stems      = {params.base .. params.strong .. params.final .. "de"}
	stems     = {pl_short_stem}
	stems       = {params.base .. params.strong .. "e", params.base .. params.strong .. params.final .. "sid"}
	
	process_stems(data, stems)
	
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " külm-type nominals")
	
	local params = get_params(args, 4, true)
	local pl_short_stem = params.base .. params.weak .. "i"
	
	if params.strong == params.weak or params.strong == params.weak .. params.weak then
		data.title = data.title .. ", length gradation"
	elseif params.strong == "eg" and params.weak == "j" then
		data.title = data.title .. ", ''g-j'' gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end

	if params.weak == "" and mw.ustring.match(params.base, "()()$") then
		pl_short_stem = nil
	else
		pl_short_stem = pl_short_stem
	end
	
	local stems = {}
	stems       = {params.base .. params.strong}
	stems           = {params.base .. params.weak .. params.final}
	stems       = {params.base .. params.strong .. params.final}
	stems = {params.base .. params.strong .. params.final}
	stems      = {params.base .. params.strong .. params.final .. "de"}
	stems     = {pl_short_stem}
	stems       = {params.base .. params.strong .. "i", params.base .. params.strong .. params.final .. "sid"}
	
	process_stems(data, stems)
	
end
	
inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " leib-type nominals")
	
	local params = get_params(args, 4, true)
	local pl_short_stem = params.base .. params.weak .. "u"
	
	if params.strong == params.weak or params.strong == params.weak .. params.weak then
		data.title = data.title .. ", length gradation"
	elseif params.strong == "tv" and params.weak == "dv" then -- only for the word "lõtv"
		data.title = data.title .. ", length gradation"
	elseif params.strong == "eg" and params.weak == "j" then
		data.title = data.title .. ", ''g-j'' gradation"
	elseif params.strong == "ed" and params.weak == "i" then
		data.title = data.title .. ", ''d-ø'' gradation"
	else
		data.title = data.title .. ", ''" .. params.strong .. "-" .. (params.weak == "" and "ø" or params.weak) .. "'' gradation"
	end

	if params.weak == "" and mw.ustring.match(params.base, "()()$") then
		pl_short_stem = nil
	else
		pl_short_stem = pl_short_stem
	end
	
	local stems = {}
	stems       = {params.base .. params.strong}
	stems           = {params.base .. params.weak .. params.final}
	stems       = {params.base .. params.strong .. params.final}
	stems = {params.base .. params.strong .. params.final}
	stems      = {params.base .. params.strong .. params.final .. "de"}
	stems     = {pl_short_stem}
	stems       = {params.base .. params.strong .. "u", params.base .. params.strong .. params.final .. "sid"}
	
	process_stems(data, stems)
	
end

inflections = function(args, data)
	data.title = "ÕS type ], length gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " puri-type nominals")
	
	local params = get_params(args, 3)
	
	local stems = {}
	stems       = {params.base .. params.final_nom_sg}
	stems           = {params.base .. params.final}
	stems       = {params.base .. params.final}
	stems = {params.base .. params.final}
	stems      = {params.base .. params.final .. "de"}
	stems     = {}
	stems       = {params.base .. params.final .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " tühi-type nominals")
	
	local params = get_params(args, 5, true)
	local weak_pl_stem = params.base .. params.weak .. params.final
	local strong_pl_stem = params.base .. params.strong .. params.final
	
	if mw.ustring.find(params.final, "a$") then 
		weak_pl_stem = mw.ustring.gsub(params.base .. params.weak .. params.final, "a$", "e")
		strong_pl_stem = mw.ustring.gsub(params.base .. params.strong .. params.final, "a$", "e")
	elseif mw.ustring.find(params.final, "u$") then 
		weak_pl_stem = mw.ustring.gsub(params.base .. params.weak .. params.final, "u$", "e")
		strong_pl_stem = mw.ustring.gsub(params.base .. params.strong .. params.final, "u$", "e")
	end
	
	if params.strong == "t" and params.weak == "" then
		data.title = data.title .. ", ''" .. (params.weak == "" and "ø" or params.weak) .. "-" .. params.strong .. "'' gradation"
	else
		data.title = data.title .. ", length gradation"
	end

	local stems = {}
	stems       = {params.base .. params.weak .. params.final_nom_sg}
	stems           = {params.base .. params.weak .. params.final}
	stems       = {params.base .. params.strong .. params.final}
	stems = {params.base .. params.strong .. params.final}
	stems      = {params.base .. params.strong .. params.final .. "de"}
	stems     = {weak_pl_stem}
	stems       = {strong_pl_stem, params.base .. params.strong .. params.final .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ]"
	table.insert(data.categories, lang:getCanonicalName() .. " oder-type nominals")
	
	local params = get_params(args, 5, true)
	local weak_pl_stem = params.base .. params.weak .. params.final
	local strong_pl_stem = params.base .. params.strong .. params.final

	if mw.ustring.find(params.final, "a$") then 
		weak_pl_stem = mw.ustring.gsub(params.base .. params.weak .. params.final, "a$", "i")
		strong_pl_stem = mw.ustring.gsub(params.base .. params.strong .. params.final, "a$", "i")
	elseif mw.ustring.find(params.final, "e$") then 
		weak_pl_stem = mw.ustring.gsub(params.base .. params.weak .. params.final, "e$", "i")
		strong_pl_stem = mw.ustring.gsub(params.base .. params.strong .. params.final, "e$", "i")
	end
	
	if params.strong == "t" and params.weak == "" then
		data.title = data.title .. ", ''" .. (params.weak == "" and "ø" or params.weak) .. "-" .. params.strong .. "'' gradation"
	else
		data.title = data.title .. ", length gradation"
	end

	local stems = {}
	stems       = {params.base .. params.weak .. params.final_nom_sg}
	stems           = {params.base .. params.weak .. params.final}
	stems       = {params.base .. params.strong .. params.final}
	stems = {params.base .. params.strong .. params.final}
	stems      = {params.base .. params.strong .. params.final .. "de"}
	stems     = {weak_pl_stem}
	stems       = {strong_pl_stem, params.base .. params.strong .. params.final .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], length gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " padi-type nominals")
	
	local params = get_params(args, 5, true)
	local weak_pl_stem = mw.ustring.gsub(params.base .. params.weak .. params.final, "a$", "u")
	local strong_pl_stem = mw.ustring.gsub(params.base .. params.strong .. params.final, "a$", "u")
	
	local stems = {}
	stems       = {params.base .. params.weak .. params.final_nom_sg}
	stems           = {params.base .. params.weak .. params.final}
	stems       = {params.base .. params.strong .. params.final}
	stems = {params.base .. params.strong .. params.final}
	stems      = {params.base .. params.strong .. params.final .. "de"}
	stems     = {weak_pl_stem}
	stems       = {strong_pl_stem, params.base .. params.strong .. params.final .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], length gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " õnnelik-type nominals")
	
	local params = get_params(args, 1)
	
	local stems = {}
	stems       = {params.base .. "k"}
	stems           = {params.base .. "ku"}
	stems       = {params.base .. "kku"}
	stems = {params.base .. "kku"}
	stems      = {params.base .. "ke", params.base .. "kkude"}
	stems     = {}
	stems       = {params.base .. "kke", params.base .. "kkusid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " koi-type nominals")
	
	local params = get_params(args, 1)
	local par_sg = args; if par_sg == "" then par_sg = nil end  -- For nõu
	
	local stems = {}
	stems       = {params.base}
	stems           = {params.base}
	stems       = {par_sg or params.base .. "d"}
	stems = {}
	stems      = {params.base .. "de"}
	stems     = {}
	stems       = {params.base .. "sid"}
	
	process_stems(data, stems)
end

inflections = function(args, data)
	data.title = "ÕS type ], no gradation"
	table.insert(data.categories, lang:getCanonicalName() .. " idee-type nominals")
	
	local params = get_params(args, 1)
	local ill_sg2 = args; if ill_sg2 == "" then ill_sg2 = nil end
	local shortened_stem, vowel = mw.ustring.match(params.base, "^(.-)(?)$")
	
	if mw.ustring.find(params.base, "ea$") then 
		shortened_stem = mw.ustring.gsub(params.base, "ea$", "ä")
	end 
	
	local stems = {}
	stems       = {params.base}
	stems           = {params.base}
	stems       = {params.base .. "d"}
	stems = {}
	stems      = {params.base .. "de"}
	stems     = {shortened_stem .. "i"}
	stems       = {shortened_stem .. "id", params.base .. "sid"}
	
	process_stems(data, stems)
	
	if ill_sg2 then
		table.insert(data.forms, shortened_stem .. "h" .. vowel)
	end
end


-- Helper functions

local function combine(forms1, forms2)
	if forms1 and forms2 then
		local ret = mw.clone(forms1)
		
		for _, form in ipairs(forms2) do
			table.insert(ret, form)
		end
		
		return ret
	elseif forms1 then
		return mw.clone(forms1)
	elseif forms2 then
		return mw.clone(forms2)
	else
		return nil
	end
end

function postprocess(args, data)
	local n = args; if n == "" then n = nil end
	
	data.forms = combine(data.forms, data.forms)
	
	for _, case in ipairs({"ill", "ine", "ela", "all", "ade", "abl", "tra"}) do
		data.forms = combine(data.forms, data.forms)
	end
	
	if n == "pl" then
		table.insert(data.categories, lang:getCanonicalName() .. " pluralia tantum")
	end
	
	-- TODO: This says "nouns", but this module is also used for adjectives!
	if n == "sg" then
		table.insert(data.categories, lang:getCanonicalName() .. " uncountable nouns")
	end
	
	for key, form in pairs(data.forms) do
		-- Do not show singular or plural forms for nominals that don't have them
		if (n == "pl" and key:find("_sg$")) or (n == "sg" and key:find("_pl$")) then
			form = nil
		end
		
		data.forms = form
	end
	
	-- Check if the lemma form matches the page name
	if (lang:makeEntryName(data.forms)) ~= mw.title.getCurrentTitle().text then
		table.insert(data.categories, lang:getCanonicalName() .. " entries with inflection not matching pagename")
	end
end

-- Make the table
function make_table(data)
	local function show_form(form)
		if not form then
			return "—"
		elseif type(form) ~= "table" then
			error("a non-table value was given in the list of inflected forms.")
		end
		
		local ret = {}
		
		for key, subform in ipairs(form) do
			table.insert(ret, m_links.full_link({lang = lang, term = subform}))
		end
		
		return table.concat(ret, "<br/>")
	end
	
	local function repl(param)
		if param == "lemma" then
			return m_links.full_link({lang = lang, alt = mw.title.getCurrentTitle().text}, "term")
		elseif param == "info" then
			return data.title and " (" .. data.title .. ")" or ""
		else
			return show_form(data.forms)
		end
	end
	
	local wikicode = [=[
{| class="inflection-table vsSwitcher" data-toggle-category="declension" style="border: solid 1px var(--wikt-palette-blue-2,#ccccff); text-align:left;" cellspacing="1" cellpadding="2"
|-
! class="vsToggleElement" colspan="4" style="background:var(--wikt-palette-blue-2,#ccccff);" | Declension of {{{lemma}}}{{{info}}}
|- class="vsHide"
! style="min-width: 11em; background:var(--wikt-palette-blue-2,#ccccff);" colspan="2" |
! style="min-width: 10em; background:var(--wikt-palette-blue-2,#ccccff);" | singular
! style="min-width: 10em; background:var(--wikt-palette-blue-2,#ccccff);" | plural
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | nominative
| rowspan="2" | {{{nom_sg}}}
| rowspan="3" | {{{nom_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! rowspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | accusative
! style="background:var(--wikt-palette-blue-1,#e0ffe0);" | nom.
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! style="background:var(--wikt-palette-blue-1,#e0ffe0);" | gen.
| rowspan="2" | {{{gen_sg}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | genitive
| {{{gen_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | partitive
| {{{par_sg}}}
| {{{par_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | illative
| {{{ill_sg}}}
| {{{ill_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | inessive
| {{{ine_sg}}}
| {{{ine_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | elative
| {{{ela_sg}}}
| {{{ela_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | allative
| {{{all_sg}}}
| {{{all_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | adessive
| {{{ade_sg}}}
| {{{ade_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | ablative
| {{{abl_sg}}}
| {{{abl_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | translative
| {{{tra_sg}}}
| {{{tra_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | terminative
| {{{ter_sg}}}
| {{{ter_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | essive
| {{{ess_sg}}}
| {{{ess_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | abessive
| {{{abe_sg}}}
| {{{abe_pl}}}
|- class="vsHide" style="background:var(--wikt-palette-blue-0,#f2ffff)"
! colspan="2" style="background:var(--wikt-palette-blue-2,#ccccff);" | comitative
| {{{com_sg}}}
| {{{com_pl}}}
|}]=]
	return mw.ustring.gsub(wikicode, "{{{(+)}}}", repl)
end

return export