Module:se-pronouns

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

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

local export = {}

-- 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[1] or error("Inflection type has not been specified. Please pass parameter 1 to the module invocation.") local args = frame:getParent.args if not inflections[infl_type] then error("Unknown inflection type '" .. infl_type .. "'.") end local data = {forms = {}, title = nil, categories = {}} -- Generate the forms inflections[infl_type](args, data) -- Postprocess postprocess(args, data) return make_table(data) .. m_utilities.format_categories(data.categories, lang) end

-- Inflection functions

inflections["ppron"] = function(args, data) data.title = "irregular" data.single = true local nom = args[1]; if nom == "" then nom = nil end if not nom and mw.title.getCurrentTitle.nsText == "Template" then nom = "mun" end local first = mw.ustring.sub(nom, 1, 1) if nom == "mun" or nom == "don" or nom == "son" then data.forms["nom"] = {first .. "on"} data.forms["acc"] = {first .. "ū"} data.forms["gen"] = {first .. "ū"} data.forms["ill"] = {first .. "u" .. (first == "m" and "n" or "t") .. "nje"} data.forms["loc"] = {first .. "ūs"} data.forms["com"] = {first .. "uinna"} data.forms["ess"] = {first .. "ūnin"} if nom == "mun" then table.insert(data.forms["nom"], 1, "mun") end elseif nom == "moai" or nom == "doai" or nom == "soai" then data.forms["nom"] = {first .. "oai"} data.forms["acc"] = {first .. "u" .. (first == "m" and "nˈ" or "d") .. "no"} data.forms["gen"] = {first .. "u" .. (first == "m" and "nˈ" or "d") .. "no"} data.forms["ill"] = {first .. "u" .. (first == "m" and "nˈ" or "d") .. "nuide"} data.forms["loc"] = {first .. "u" .. (first == "m" and "nˈ" or "d") .. "nos"} data.forms["com"] = {first .. "u" .. (first == "m" and "nˈ" or "d") .. "nuin"} data.forms["ess"] = {first .. "u" .. (first == "m" and "nˈ" or "d") .. "non"} elseif nom == "mii" or nom == "dii" or nom == "sii" then data.forms["nom"] = {first .. "ii"} data.forms["acc"] = {first .. "īn"} data.forms["gen"] = {first .. "īn"} data.forms["ill"] = {first .. "idjiide"} data.forms["loc"] = {first .. "īs"} data.forms["com"] = {first .. "īnguin"} data.forms["ess"] = {first .. "īnin"} else error("Invalid pronoun.") end end

function postprocess(args, data) -- 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.text) or (data.forms["nom"] and (lang:makeEntryName(data.forms["nom"][1])) ~= 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 "&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({lang = lang, term = subform})) end return table.concat(ret, ", ") 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[param]) end end local wikicode if data.single then wikicode = [=[ else wikicode = [=[ end return mw.ustring.gsub(wikicode, "", repl) end

return export