Module:Fiu-fin-nominals

local m_utilities = require("Module:utilities") local m_links = require("Module:links") local m_common = require("Module:fiu-fin-common")

local export = {}

local lang = require("Module:languages").getByCode("fiu-fin-pro")

-- 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 args = frame:getParent.args local data = {forms = {}, title = nil, categories = {}} -- Generate the forms inflect(args, data) -- Apply gradation for key, forms in pairs(data.forms) do		for i, form in ipairs(forms) do			forms[i] = m_common.apply_gradation(form) end end -- Check if the lemma form matches the page name if data.forms["nom_sg"] and lang:makeEntryName(data.forms["nom_sg"][1]) ~= mw.title.getCurrentTitle.subpageText then table.insert(data.categories, lang:getCanonicalName .. " entries with inflection not matching pagename") end return make_table(data) .. m_utilities.format_categories(data.categories, lang) end

function inflect(args, data) local prefix = args[1] or "" local stem = args[2] or "" if stem == "" then stem = prefix prefix = "" end if stem == "" then if mw.title.getCurrentTitle.nsText == "Template" then stem = "-" else error("Parameter 1 (stem) must be provided") end end local vowels = m_common.detect_harmony(stem) local stems = m_common.make_stems((mw.ustring.gsub(stem, "([aeiouäöü])nen$", "%1c")), true) if mw.ustring.find(stem, "[aeiouäöü]nen$") then stems.final = stem end make_forms(stems, vowels, data) if mw.ustring.find(stem, "^[mc]inu$") then data.forms["nom_sg"] = {(mw.ustring.gsub(stem, "u$", "ä"))} data.forms["acc_sg"] = {stem .. "t"} for key, form in pairs(data.forms) do			if key:find("_pl") then data.forms[key] = nil end end elseif mw.ustring.find(stem, "^[mt]e$") then data.forms["nom_pl"] = {stem, (mw.ustring.gsub(stem, "e$", "öö"))} data.forms["acc_pl"] = {stem .. "det", stem .. "idet"} for key, form in pairs(data.forms) do			if key:find("_sg") then data.forms[key] = nil end end elseif stem == "hän" then data.forms["nom_sg"] = {"hän"} data.forms["acc_sg"] = {"hänet"} for key, form in pairs(data.forms) do			if key:find("_pl") then data.forms[key] = nil end end end for key, subforms in pairs(data.forms) do		for i, form in ipairs(subforms) do subforms[i] = prefix .. form end end for _, t in ipairs(stems.types) do table.insert(data.categories, "Proto-Finnic nominals by type/" .. t)	end end

function make_forms(stems, vowels, data) data.forms["nom_sg"] = {stems.final} data.forms["acc_sg"] = {stems.normal .. "n"} data.forms["gen_sg"] = {stems.normal .. "n"} data.forms["par_sg"] = {stems.t .. vowels.a} data.forms["ine_sg"] = {stems.normal .. "ss" .. vowels.a} data.forms["ela_sg"] = {stems.normal .. "st" .. vowels.a} data.forms["ill_sg"] = {stems.normal .. "sen"} data.forms["ade_sg"] = {stems.normal .. "ll" .. vowels.a} data.forms["abl_sg"] = {stems.normal .. "lt" .. vowels.a} data.forms["all_sg"] = {stems.normal .. "lek"} data.forms["ess_sg"] = {stems.n .. vowels.a} data.forms["tra_sg"] = {stems.normal .. "ksi"} data.forms["com_sg"] = {stems.n .. "ek"} data.forms["ins_sg"] = {stems.normal .. "n"} data.forms["abe_sg"] = {stems.normal .. "kt" .. vowels.a} data.forms["nom_pl"] = {stems.normal .. "t"} data.forms["acc_pl"] = {stems.normal .. "t"} data.forms["gen_pl"] = {stems.t .. "en", stems.i .. "ten"} data.forms["par_pl"] = {stems.i .. "t" .. vowels.a} data.forms["ine_pl"] = {stems.i .. "ss" .. vowels.a} data.forms["ela_pl"] = {stems.i .. "st" .. vowels.a} data.forms["ill_pl"] = {stems.i .. "sen"} data.forms["ade_pl"] = {stems.i .. "ll" .. vowels.a} data.forms["abl_pl"] = {stems.i .. "lt" .. vowels.a} data.forms["all_pl"] = {stems.i .. "lek"} data.forms["ess_pl"] = {stems.i .. "n" .. vowels.a} data.forms["tra_pl"] = {stems.i .. "ksi"} data.forms["com_pl"] = {stems.i .. "nek"} data.forms["ins_pl"] = {stems.i .. "n"} data.forms["abe_pl"] = {stems.i .. "kt" .. vowels.a} end

-- Functions for generating the inflection table

function show_form(form) if not form then return "&mdash;" 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(nil, "*" .. subform, lang, nil, nil, nil, {}, false)) end return table.concat(ret, " ") end

-- Make the table function make_table(data) return [=[ ]=]

end

return export