モジュール:sl-noun

出典: フリー多機能辞典『ウィクショナリー日本語版(Wiktionary)』
ナビゲーションに移動 検索に移動

このモジュールについての説明文ページを モジュール:sl-noun/doc に作成できます

local export = {}

local lang = require("モジュール:languages").getByCode("sl")

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

-- Checks each form for the presence of accent marks.
-- If any form doesn't contain any accent marks, flag the entry for attention.
local function check_accents(args, data)
	-- Do we need to check?
	local noacc = args["noacc"]; if noacc == "" then noacc = nil end
	
	if noacc then
		return
	end
	
	-- Yes, we do need to check.
	for key, subforms in pairs(data.forms) do
		for key2, subform in ipairs(subforms) do
			if not require("モジュール:sl-common").has_accents(subform) then
				table.insert(data.categories, "スロヴェニア語 名詞 アクセント未入力")
				return  -- So that we don't add the category more than once
			end
		end
	end
end

-- 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[1] or error("Inflection type has not been specified.")
	local args = frame:getParent().args
	local num = args["n"]; if num == "" then num = nil end
	
	local data = {forms = {}, info = nil, categories = {}, num = num}
	
	if inflections[infl_type] then
		inflections[infl_type](args, data)
	else
		error("Unknown inflection type '" .. infl_type .. "'")
	end
	
	check_accents(args, data)
	
	return make_table(data)
end

-- Masculine o-stem
inflections["m"] = function(args, data)
	local stem_noending = args[1]; if stem_noending == "" then stem_noending = nil end
	local stem = args[2]; if stem == "" then stem = nil end
	local anim = args["a"]; if not anim or anim == "" then anim = false else anim = true end
	
	local nom_pl = args["nom_pl"]; if nom_pl == "" then nom_pl = nil end
	local nom_pl2 = args["nom_pl2"]; if nom_pl2 == "" then nom_pl2 = nil end
	
	if not stem_noending then
		if mw.title.getCurrentTitle().nsText == "テンプレート" then
			stem_noending = "-"
		else
			error("1st parameter (stem) has not been specified.")
		end
	end
	
	if not stem then
		stem = stem_noending
		stem_noending = make_endingless_stem(stem)
	end
	
	-- Is this a hard stem or a soft stem?
	local oe = "o"
	local hs = "硬変化"
	data.info = "男性 " .. (anim and "活動体" or "不活動体")
	
	if require("モジュール:sl-common").is_soft(stem) then
		oe = "e"
		hs = "軟変化"
	end
	
	data.info = data.info .. ", " .. hs .. " o語幹"
	table.insert(data.categories, "スロヴェニア語 男性" .. hs .. "o語幹名詞")
	
	-- Categorize further
	local stem_noaccents = require("モジュール:sl-common").remove_accents(stem)
	local stem_noending_noaccents = require("モジュール:sl-common").remove_accents(stem_noending)
	local corrected_stem = nil
	
	if stem_noaccents == stem_noending_noaccents then
		corrected_stem = stem_noending
	elseif stem_noaccents == mw.ustring.gsub(stem_noending_noaccents, "e([ln]j)$", "%1") then
		corrected_stem = mw.ustring.gsub(stem_noending, "e([ln]j)$", "%1")
	elseif stem_noaccents == mw.ustring.gsub(stem_noending_noaccents, "e(.)$", "%1") then
		corrected_stem = mw.ustring.gsub(stem_noending, "e(.)$", "%1")
	elseif stem_noaccents == mw.ustring.gsub(stem_noending_noaccents, "[aeiou]$", "") then
		table.insert(data.categories, "Slovene masculine o-stem nouns with final vowel")
		corrected_stem = mw.ustring.gsub(stem_noending, "[aeiou]$", "")
	elseif stem_noaccents == stem_noending_noaccents .. "j" then
		table.insert(data.categories, "Slovene masculine soft o-stem nouns with j-infix")
		corrected_stem = stem_noending .. "j"
	elseif stem_noaccents == stem_noending_noaccents .. "-j" then
		table.insert(data.categories, "Slovene masculine soft o-stem nouns with j-infix")
		corrected_stem = stem_noending .. "-j"
	elseif stem_noaccents == stem_noending_noaccents .. "n" then
		table.insert(data.categories, "Slovene masculine hard o-stem nouns with n-infix")
		corrected_stem = stem_noending .. "n"
	elseif stem_noaccents == stem_noending_noaccents .. "t" then
		table.insert(data.categories, "Slovene masculine hard o-stem nouns with t-infix")
		corrected_stem = stem_noending .. "t"
	else
		table.insert(data.categories, "スロヴェニア語 不規則名詞")
	end
	
	if corrected_stem and stem ~= corrected_stem then
		table.insert(data.categories, "Slovene nouns with accent alternations")
	end
	
	-- Singular
	data.forms["nom_sg"] = {stem_noending}
	data.forms["acc_sg"] = {anim and stem .. "a" or stem_noending}
	data.forms["gen_sg"] = {stem .. "a"}
	data.forms["dat_sg"] = {stem .. "u"}
	data.forms["loc_sg"] = {stem .. "u"}
	data.forms["ins_sg"] = {stem .. oe .. "m"}
	
	-- Dual
	data.forms["nom_du"] = {stem .. "a"}
	data.forms["acc_du"] = {stem .. "a"}
	data.forms["gen_du"] = {stem .. oe .. "v"}
	data.forms["dat_du"] = {stem .. oe .. "ma"}
	data.forms["loc_du"] = {stem .. "ih"}
	data.forms["ins_du"] = {stem .. oe .. "ma"}
	
	-- Plural
	data.forms["nom_pl"] = {nom_pl or stem .. "i", nom_pl2}
	data.forms["acc_pl"] = {stem .. "e"}
	data.forms["gen_pl"] = {stem .. oe .. "v"}
	data.forms["dat_pl"] = {stem .. oe .. "m"}
	data.forms["loc_pl"] = {stem .. "ih"}
	data.forms["ins_pl"] = {stem .. "i"}
end

-- Masculine o-stem, plural in -ôv-
inflections["m-ov"] = function(args, data)
	local stem_noending = args[1]; if stem_noending == "" then stem_noending = nil end
	local stem = args[2]; if stem == "" then stem = nil end
	local gen_sg_ending = args[3]; if gen_sg_ending == "" then gen_sg_ending = nil end
	local anim = args["a"]; if not anim or anim == "" then anim = false else anim = true end
	
	if not stem_noending then
		if mw.title.getCurrentTitle().nsText == "テンプレート" then
			stem_noending = "-"
		else
			error("第1パラメータが指定されていません。")
		end
	end
	
	if not stem then
		stem = stem_noending
		stem_noending = make_endingless_stem(stem)
	end
	
	local stem_noaccents = require("モジュール:sl-common").remove_accents(stem)
	
	local gen_sg = stem .. "a"
	
	if gen_sg_ending == "á" or gen_sg_ending == "ú" then
		gen_sg = stem_noaccents .. gen_sg_ending
	elseif gen_sg_ending then
		error("第3パラメータは \"á\"\"ú\"でなければなりません。")
	end
	
	-- Is this a hard stem or a soft stem?
	local oe = "o"
	local hs = "硬変化"
	data.info = "男性 " .. (anim and "活動体" or "不活動体")
	
	if require("モジュール:sl-common").is_soft(stem) then
		oe = "e"
		hs = "軟変化"
	end
	
	data.info = data.info .. ", " .. hs .. " o語幹"
	table.insert(data.categories, "スロヴェニア語 男性" .. hs .. "o語幹名詞")
	
	if gen_sg_ending then
		data.info = data.info .. ", mobile accent"
		table.insert(data.categories, "Slovene masculine o-stem nouns with mobile accent")
	end
	
	if data.num ~= "sg" then
		data.info = data.info .. ", plural in " .. require("モジュール:links").full_link({lang = lang, alt = "-ôv-"}, "term")
		table.insert(data.categories, "Slovene masculine o-stem nouns with plural in -ov-")
	end
	
	-- Categorize further
	local stem_noending_noaccents = require("モジュール:sl-common").remove_accents(stem_noending)
	local corrected_stem = nil
	
	if stem_noaccents == stem_noending_noaccents then
		corrected_stem = stem_noending
	elseif stem_noaccents == mw.ustring.gsub(stem_noending_noaccents, "e([ln]j)$", "%1") then
		corrected_stem = mw.ustring.gsub(stem_noending, "e([ln]j)$", "%1")
	elseif stem_noaccents == mw.ustring.gsub(stem_noending_noaccents, "e(.)$", "%1") then
		corrected_stem = mw.ustring.gsub(stem_noending, "e(.)$", "%1")
	elseif stem_noaccents == mw.ustring.gsub(stem_noending_noaccents, "[aeiou]$", "") then
		table.insert(data.categories, "Slovene masculine o-stem nouns with final vowel")
		corrected_stem = mw.ustring.gsub(stem_noending, "[aeiou]$", "")
	elseif stem_noaccents == stem_noending_noaccents .. "j" then
		table.insert(data.categories, "Slovene masculine soft o-stem nouns with j-infix")
		corrected_stem = stem_noending .. "j"
	elseif stem_noaccents == stem_noending_noaccents .. "-j" then
		table.insert(data.categories, "Slovene masculine soft o-stem nouns with j-infix")
		corrected_stem = stem_noending .. "-j"
	elseif stem_noaccents == stem_noending_noaccents .. "n" then
		table.insert(data.categories, "Slovene masculine hard o-stem nouns with n-infix")
		corrected_stem = stem_noending .. "n"
	elseif stem_noaccents == stem_noending_noaccents .. "t" then
		table.insert(data.categories, "Slovene masculine hard o-stem nouns with t-infix")
		corrected_stem = stem_noending .. "t"
	else
		table.insert(data.categories, "スロヴェニア語 不規則名詞")
	end
	
	if corrected_stem and stem ~= corrected_stem then
		table.insert(data.categories, "Slovene nouns with accent alternations")
	end
	
	-- Singular
	data.forms["nom_sg"] = {stem_noending}
	data.forms["acc_sg"] = {anim and gen_sg or stem_noending}
	data.forms["gen_sg"] = {gen_sg}
	data.forms["dat_sg"] = {stem .. "u"}
	data.forms["loc_sg"] = {stem .. "u"}
	data.forms["ins_sg"] = {stem .. oe .. "m"}
	
	-- Dual
	data.forms["nom_du"] = {stem_noaccents .. "ôva"}
	data.forms["acc_du"] = {stem_noaccents .. "ôva"}
	data.forms["gen_du"] = {stem_noaccents .. "ôv"}
	data.forms["dat_du"] = {stem_noaccents .. "ôvoma"}
	data.forms["loc_du"] = {stem_noaccents .. "ôvih"}
	data.forms["ins_du"] = {stem_noaccents .. "ôvoma"}
	
	-- Plural
	data.forms["nom_pl"] = {stem_noaccents .. "ôvi"}
	data.forms["acc_pl"] = {stem_noaccents .. "ôve"}
	data.forms["gen_pl"] = {stem_noaccents .. "ôv"}
	data.forms["dat_pl"] = {stem_noaccents .. "ôvom"}
	data.forms["loc_pl"] = {stem_noaccents .. "ôvih"}
	data.forms["ins_pl"] = {stem_noaccents .. "ôvi"}
end

-- Masculine a-stem
inflections["m-a"] = function(args, data)
	local stem = args[1]; if stem == "" then stem = nil end
	local anim = args["a"]; if not anim or anim == "" then anim = false else anim = true end
	
	if not stem then
		if mw.title.getCurrentTitle().nsText == "テンプレート" then
			stem = "-"
		else
			error("第1パラメータが指定されていません。")
		end
	end
	
	local stem_noending = make_endingless_stem(stem)
	
	data.info = "男性 " .. (anim and "活動体" or "不活動体") .. ", a語幹"
	table.insert(data.categories, "スロヴェニア語 男性a語幹名詞")
	
	-- Singular
	data.forms["nom_sg"] = {stem .. "a"}
	data.forms["acc_sg"] = {stem .. "o"}
	data.forms["gen_sg"] = {stem .. "e"}
	data.forms["dat_sg"] = {stem .. "i"}
	data.forms["loc_sg"] = {stem .. "i"}
	data.forms["ins_sg"] = {stem .. "o"}
	
	-- Dual
	data.forms["nom_du"] = {stem .. "i"}
	data.forms["acc_du"] = {stem .. "i"}
	data.forms["gen_du"] = {stem_noending}
	data.forms["dat_du"] = {stem .. "ama"}
	data.forms["loc_du"] = {stem .. "ah"}
	data.forms["ins_du"] = {stem .. "ama"}
	
	-- Plural
	data.forms["nom_pl"] = {stem .. "e"}
	data.forms["acc_pl"] = {stem .. "e"}
	data.forms["gen_pl"] = {stem_noending}
	data.forms["dat_pl"] = {stem .. "am"}
	data.forms["loc_pl"] = {stem .. "ah"}
	data.forms["ins_pl"] = {stem .. "ami"}
end

-- Feminine a-stem
inflections["f"] = function(args, data)
	local stem = args[1]; if stem == "" then stem = nil end
	
	if not stem then
		if mw.title.getCurrentTitle().nsText == "テンプレート" then
			stem = "-"
		else
			error("第1パラメータが指定されていません。")
		end
	end
	
	local stem_noending = make_endingless_stem(stem)
	
	data.info = "女性, a語幹"
	table.insert(data.categories, "スロヴェニア語 女性a語幹名詞")
	
	-- Singular
	data.forms["nom_sg"] = {stem .. "a"}
	data.forms["acc_sg"] = {stem .. "o"}
	data.forms["gen_sg"] = {stem .. "e"}
	data.forms["dat_sg"] = {stem .. "i"}
	data.forms["loc_sg"] = {stem .. "i"}
	data.forms["ins_sg"] = {stem .. "o"}
	
	-- Dual
	data.forms["nom_du"] = {stem .. "i"}
	data.forms["acc_du"] = {stem .. "i"}
	data.forms["gen_du"] = {stem_noending}
	data.forms["dat_du"] = {stem .. "ama"}
	data.forms["loc_du"] = {stem .. "ah"}
	data.forms["ins_du"] = {stem .. "ama"}
	
	-- Plural
	data.forms["nom_pl"] = {stem .. "e"}
	data.forms["acc_pl"] = {stem .. "e"}
	data.forms["gen_pl"] = {stem_noending}
	data.forms["dat_pl"] = {stem .. "am"}
	data.forms["loc_pl"] = {stem .. "ah"}
	data.forms["ins_pl"] = {stem .. "ami"}
end

-- Feminine a-stem, mobile accent paradigm
inflections["f-mobile"] = function(args, data)
	local stem = args[1]; if stem == "" then stem = nil end
	local gen_pl = args["gen_pl"]; if gen_pl == "" then gen_pl = nil end
	
	if not stem then
		if mw.title.getCurrentTitle().nsText == "テンプレート" then
			stem = "-"
		else
			error("第1パラメータが指定されていません。")
		end
	end
	
	local stem_noaccents = require("モジュール:sl-common").remove_accents(stem)
	gen_pl = gen_pl or stem_noaccents .. "á"
	
	data.info = "女性, a語幹, mobile accent"
	table.insert(data.categories, "スロヴェニア語 女性a語幹名詞")
	table.insert(data.categories, "Slovene feminine a-stem nouns with mobile accent")
	
	-- Singular
	data.forms["nom_sg"] = {stem .. "a"}
	data.forms["acc_sg"] = {stem_noaccents .. "ó"}
	data.forms["gen_sg"] = {stem_noaccents .. "é"}
	data.forms["dat_sg"] = {stem .. "i"}
	data.forms["loc_sg"] = {stem .. "i"}
	data.forms["ins_sg"] = {stem_noaccents .. "ó"}
	
	-- Dual
	data.forms["nom_du"] = {stem_noaccents .. "é"}
	data.forms["acc_du"] = {stem_noaccents .. "é"}
	data.forms["gen_du"] = {gen_pl}
	data.forms["dat_du"] = {stem_noaccents .. "áma"}
	data.forms["loc_du"] = {stem_noaccents .. "àh"}
	data.forms["ins_du"] = {stem_noaccents .. "áma"}
	
	-- Plural
	data.forms["nom_pl"] = {stem_noaccents .. "é"}
	data.forms["acc_pl"] = {stem_noaccents .. "é"}
	data.forms["gen_pl"] = {gen_pl}
	data.forms["dat_pl"] = {stem_noaccents .. "àm"}
	data.forms["loc_pl"] = {stem_noaccents .. "àh"}
	data.forms["ins_pl"] = {stem_noaccents .. "ámi"}
end

-- Feminine v-stem
inflections["f-v"] = function(args, data)
	local stem = args[1]; if stem == "" then stem = nil end
	
	if not stem then
		if mw.title.getCurrentTitle().nsText == "テンプレート" then
			stem = "-"
		else
			error("第1パラメータが指定されていません。")
		end
	end
	
	local stem_noending = stem .. "ev"
	stem = stem .. "v"
	
	data.info = "女性, v語幹"
	table.insert(data.categories, "スロヴェニア語 女性v語幹名詞")
	
	-- Singular
	data.forms["nom_sg"] = {stem_noending}
	data.forms["acc_sg"] = {stem_noending}
	data.forms["gen_sg"] = {stem .. "e"}
	data.forms["dat_sg"] = {stem .. "i"}
	data.forms["loc_sg"] = {stem .. "i"}
	data.forms["ins_sg"] = {stem .. "ijo"}
	
	-- Dual
	data.forms["nom_du"] = {stem .. "i"}
	data.forms["acc_du"] = {stem .. "i"}
	data.forms["gen_du"] = {stem_noending}
	data.forms["dat_du"] = {stem .. "ama"}
	data.forms["loc_du"] = {stem .. "ah"}
	data.forms["ins_du"] = {stem .. "ama"}
	
	-- Plural
	data.forms["nom_pl"] = {stem .. "e"}
	data.forms["acc_pl"] = {stem .. "e"}
	data.forms["gen_pl"] = {stem_noending}
	data.forms["dat_pl"] = {stem .. "am"}
	data.forms["loc_pl"] = {stem .. "ah"}
	data.forms["ins_pl"] = {stem .. "ami"}
end

-- Feminine i-stem
inflections["f-i"] = function(args, data)
	local stem = args[1]; if stem == "" then stem = nil end
	
	if not stem then
		if mw.title.getCurrentTitle().nsText == "テンプレート" then
			stem = "-"
		else
			error("第1パラメータが指定されていません。")
		end
	end
	
	local stem_noending = make_endingless_stem(stem)
	
	data.info = "女性, i語幹"
	table.insert(data.categories, "スロヴェニア語 女性i語幹名詞")
	
	-- Singular
	data.forms["nom_sg"] = {stem_noending}
	data.forms["acc_sg"] = {stem_noending}
	data.forms["gen_sg"] = {stem .. "i"}
	data.forms["dat_sg"] = {stem .. "i"}
	data.forms["loc_sg"] = {stem .. "i"}
	data.forms["ins_sg"] = {stem .. (stem ~= stem_noending and "i" or "") .. "jo"}
	
	-- Dual
	data.forms["nom_du"] = {stem .. "i"}
	data.forms["acc_du"] = {stem .. "i"}
	data.forms["gen_du"] = {stem .. "i"}
	data.forms["dat_du"] = {stem .. (stem ~= stem_noending and "i" or "") .. "ma"}
	data.forms["loc_du"] = {stem .. "ih"}
	data.forms["ins_du"] = {stem .. (stem ~= stem_noending and "i" or "") .. "ma"}
	
	-- Plural
	data.forms["nom_pl"] = {stem .. "i"}
	data.forms["acc_pl"] = {stem .. "i"}
	data.forms["gen_pl"] = {stem .. "i"}
	data.forms["dat_pl"] = {stem .. "im"}
	data.forms["loc_pl"] = {stem .. "ih"}
	data.forms["ins_pl"] = {stem .. (stem ~= stem_noending and "i" or "") .. "mi"}
end

-- Feminine i-stem, mobile accent paradigm
inflections["f-i-mobile"] = function(args, data)
	local stem = args[1]; if stem == "" then stem = nil end
	local stem_dat_loc_sg = args[2]; if stem_dat_loc_sg == "" then stem_dat_loc_sg = nil end
	
	if not stem then
		if mw.title.getCurrentTitle().nsText == "テンプレート" then
			stem = "-"
		else
			error("第1パラメータが指定されていません。")
		end
	end
	
	local stem_noending = make_endingless_stem(stem)
	local stem_noaccents = require("モジュール:sl-common").remove_accents(stem)
	stem_dat_loc_sg = stem_dat_loc_sg or stem
	
	data.info = "女性, i語幹, mobile accent"
	table.insert(data.categories, "スロヴェニア語 女性i語幹名詞")
	table.insert(data.categories, "Slovene feminine i-stem nouns with mobile accent")
	
	-- Singular
	data.forms["nom_sg"] = {stem_noending}
	data.forms["acc_sg"] = {stem_noending}
	data.forms["gen_sg"] = {stem_noaccents .. "í"}
	data.forms["dat_sg"] = {stem_dat_loc_sg .. "i"}
	data.forms["loc_sg"] = {stem_dat_loc_sg .. "i"}
	data.forms["ins_sg"] = {stem_noaccents .. (stem ~= stem_noending and "i" or "") .. "jó"}
	
	-- Dual
	data.forms["nom_du"] = {stem_noaccents .. "í"}
	data.forms["acc_du"] = {stem_noaccents .. "í"}
	data.forms["gen_du"] = {stem_noaccents .. "í"}
	data.forms["dat_du"] = {stem_noaccents .. "éma"}
	data.forms["loc_du"] = {stem_noaccents .. "éh"}
	data.forms["ins_du"] = {stem_noaccents .. "éma"}
	
	-- Plural
	data.forms["nom_pl"] = {stem_noaccents .. "í"}
	data.forms["acc_pl"] = {stem_noaccents .. "í"}
	data.forms["gen_pl"] = {stem_noaccents .. "í"}
	data.forms["dat_pl"] = {stem_noaccents .. "ém"}
	data.forms["loc_pl"] = {stem_noaccents .. "éh"}
	data.forms["ins_pl"] = {stem_noaccents .. (stem ~= stem_noending and "i" or "") .. "mí"}
end

-- Neuter o-stem
inflections["n"] = function(args, data)
	local stem = args[1]; if stem == "" then stem = nil end
	
	if not stem then
		if mw.title.getCurrentTitle().nsText == "テンプレート" then
			stem = "-"
		else
			error("第1パラメータが指定されていません。")
		end
	end
	
	local stem_noending = make_endingless_stem(stem)
	
	-- Is this a hard stem or a soft stem?
	local oe = "o"
	data.info = "中性"
	
	if require("モジュール:sl-common").is_soft(stem) then
		oe = "e"
		data.info = data.info .. ", 軟変化"
		table.insert(data.categories, "スロヴェニア語 中性軟変化o語幹名詞")
	else
		data.info = data.info .. ", 硬変化"
		table.insert(data.categories, "スロヴェニア語 中性硬変化o語幹名詞")
	end
	
	-- Singular
	data.forms["nom_sg"] = {stem .. oe}
	data.forms["acc_sg"] = {stem .. oe}
	data.forms["gen_sg"] = {stem .. "a"}
	data.forms["dat_sg"] = {stem .. "u"}
	data.forms["loc_sg"] = {stem .. "u"}
	data.forms["ins_sg"] = {stem .. oe .. "m"}
	
	-- Dual
	data.forms["nom_du"] = {stem .. "i"}
	data.forms["acc_du"] = {stem .. "i"}
	data.forms["gen_du"] = {stem_noending}
	data.forms["dat_du"] = {stem .. oe .. "ma"}
	data.forms["loc_du"] = {stem .. "ih"}
	data.forms["ins_du"] = {stem .. oe .. "ma"}
	
	-- Plural
	data.forms["nom_pl"] = {stem .. "a"}
	data.forms["acc_pl"] = {stem .. "a"}
	data.forms["gen_pl"] = {stem_noending}
	data.forms["dat_pl"] = {stem .. oe .. "m"}
	data.forms["loc_pl"] = {stem .. "ih"}
	data.forms["ins_pl"] = {stem .. "i"}
end

function make_endingless_stem(stem)
	local stem_noaccents = mw.ustring.lower(require("モジュール:sl-common").remove_accents(stem))
	
	if mw.ustring.find(stem_noaccents, "[^aeioujlrv][ln]j$") then
		return mw.ustring.gsub(stem, "([ln]j)$", "e%1")
	elseif mw.ustring.find(stem_noaccents, "[^aeiouln]j$") then
		return mw.ustring.gsub(stem, "j$", "ij")
	elseif mw.ustring.find(stem_noaccents, "[^aeiou]r$") or mw.ustring.find(stem_noaccents, "[^aeioujlrv][lmnv]$") then
		return mw.ustring.gsub(stem, "(.)$", "e%1")
	else
		return stem
	end
end

-- Make the table
function make_table(data)
	local function repl(param)
		local accel = false  -- Temporary
		local no_store = false
		
		if param == "info" then
			return mw.getContentLanguage():ucfirst(data.info or "")
		elseif string.sub(param, 1, 1) == "!" then
			no_store = true
			param = string.sub(param, 2)
		elseif string.sub(param, 1, 1) == "#" then
			accel = false
			param = string.sub(param, 2)
		end
		
		local forms = data.forms[param]
		
		if not forms then
			return "—"
		end
		
		local ret = {}
		
		for key, subform in ipairs(forms) do
			table.insert(ret, require("モジュール:links").full_link({lang = lang, term = subform, accel = accel and {form = param, no_store = no_store} or nil}))
		end
		
		return table.concat(ret, "<br/>")
	end
	
	local wikicode
	
	if data.num then
		wikicode = [=[
{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="background: #F9F9F9; border: 1px solid #aaaaaa;"
|- style="background: #d9ebff; text-align: left;"
! class="vsToggleElement" colspan="2" | {{{info}}}
|- class="vsShow"
! style="width: 11em; background: #eff7ff;" | 主格
| style="width: 11em;" colspan="2" | {{{!nom_]=] .. data.num .. [=[}}}
|- class="vsShow"
! style="background: #eff7ff;" | 生格
| colspan="2" | {{{!gen_]=] .. data.num .. [=[}}}
|- class="vsHide"
! style="background: #d9ebff; width: 11em;" | 
! style="background: #d9ebff; width: 11em;" | ]=] .. (data.num == "pl" and "複数" or data.num == "du" and "双数" or "単数") .. [=[

|- class="vsHide"
! style="background:#eff7ff" | 主格
| {{{nom_]=] .. data.num .. [=[}}}
|- class="vsHide"
! style="background:#eff7ff" | 対格
| {{{acc_]=] .. data.num .. [=[}}}
|- class="vsHide"
! style="background:#eff7ff" | 生格
| {{{gen_]=] .. data.num .. [=[}}}
|- class="vsHide"
! style="background:#eff7ff" | 与格
| {{{dat_]=] .. data.num .. [=[}}}
|- class="vsHide"
! style="background:#eff7ff" | 前置格
| {{{loc_]=] .. data.num .. [=[}}}
|- class="vsHide"
! style="background:#eff7ff" | 造格
| {{{ins_]=] .. data.num .. [=[}}}
|}]=]
	else
		wikicode = [=[
{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="background: #F9F9F9; border: 1px solid #d9ebff;"
|- style="background: #d9ebff; text-align: left;"
! class="vsToggleElement" colspan="4" | {{{info}}}
|- class="vsShow"
! style="width: 11em; background: #eff7ff;" | 単数主格
| style="width: 11em;" colspan="3" | {{{!nom_sg}}}
|- class="vsShow"
! style="background: #eff7ff;" | 単数生格
| colspan="3" | {{{!gen_sg}}}
|- class="vsHide"
! style="background: #d9ebff; width: 11em;" | 
! style="background: #d9ebff; width: 11em;" | 単数
! style="background: #d9ebff; width: 11em;" | 双数
! style="background: #d9ebff; width: 11em;" | 複数
|- class="vsHide"
! style="background: #eff7ff;" | 主格
| {{{nom_sg}}}
| {{{nom_du}}}
| {{{nom_pl}}}
|- class="vsHide"
! style="background: #eff7ff;" | 対格
| {{{acc_sg}}}
| {{{acc_du}}}
| {{{acc_pl}}}
|- class="vsHide"
! style="background: #eff7ff;" | 生格
| {{{gen_sg}}}
| {{{gen_du}}}
| {{{gen_pl}}}
|- class="vsHide"
! style="background: #eff7ff;" | 与格
| {{{dat_sg}}}
| {{{dat_du}}}
| {{{dat_pl}}}
|- class="vsHide"
! style="background: #eff7ff;" | 前置格
| {{{loc_sg}}}
| {{{loc_du}}}
| {{{loc_pl}}}
|- class="vsHide"
! style="background: #eff7ff;" | 造格
| {{{ins_sg}}}
| {{{ins_du}}}
| {{{ins_pl}}}
|}]=]
	end
	
	return mw.ustring.gsub(wikicode, "{{{([^}]+)}}}", repl) .. require("モジュール:utilities").format_categories(data.categories, lang)
end

return export