Module:sl-nouns

local export = {}

local lang = require("Module: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("Module:sl-common").has_accents(subform) then table.insert(data.categories, "Requests for accents in Slovene noun entries") return -- So that we don't add the category more than once end end end end

-- Make the table local 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 "&mdash;" end local ret = {} for key, subform in ipairs(forms) do			table.insert(ret, require("Module:links").full_link({lang = lang, term = subform, accel = accel and {form = param, no_store = no_store} or nil})) end return table.concat(ret, " ") end local wikicode if data.num then wikicode = [=[ else wikicode = [=[

end return mw.ustring.gsub(wikicode, "}", repl) .. require("Module:utilities").format_categories(data.categories, lang) 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

local function make_endingless_stem(stem) local stem_noaccents = mw.ustring.lower(require("Module: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

-- 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 == "Template" 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 = "hard" data.info = "masculine " .. (anim and "anim." or "inan.") if require("Module:sl-common").is_soft(stem) then oe = "e" hs = "soft" end data.info = data.info .. ", " .. hs .. " o-stem" table.insert(data.categories, "Slovene masculine " .. hs .. " o-stem nouns") -- Categorize further local stem_noaccents = require("Module:sl-common").remove_accents(stem) local stem_noending_noaccents = require("Module: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, "Slovene irregular nouns") 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 == "Template" 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 local stem_noaccents = require("Module: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("3rd parameter (genitive singular ending) must be \"á\" or \"ú\".") end -- Is this a hard stem or a soft stem? local oe = "o" local hs = "hard" data.info = "masculine " .. (anim and "anim." or "inan.") if require("Module:sl-common").is_soft(stem) then oe = "e" hs = "soft" end data.info = data.info .. ", " .. hs .. " o-stem" table.insert(data.categories, "Slovene masculine " .. hs .. " o-stem nouns") if gen_sg_ending then data.info = data.info .. ", long mixed accent" table.insert(data.categories, "Slovene masculine o-stem nouns with long mixed accent") end if data.num ~= "sg" then data.info = data.info .. ", plural in " .. require("Module: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("Module: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, "Slovene irregular nouns") 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 == "Template" then stem = "-" else error("1st parameter (stem) has not been specified.") end end local stem_noending = make_endingless_stem(stem) data.info = "masculine " .. (anim and "anim." or "inan.") .. ", a-stem" table.insert(data.categories, "Slovene masculine a-stem nouns") -- 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 == "Template" then stem = "-" else error("1st parameter (stem) has not been specified.") end end local stem_noending = make_endingless_stem(stem) data.info = "feminine, a-stem" table.insert(data.categories, "Slovene feminine a-stem nouns") -- 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, mixed 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 == "Template" then stem = "-" else error("1st parameter (stem) has not been specified.") end end local stem_noaccents = require("Module:sl-common").remove_accents(stem) gen_pl = gen_pl or stem_noaccents .. "á" data.info = "feminine, a-stem, long mixed accent" table.insert(data.categories, "Slovene feminine a-stem nouns") table.insert(data.categories, "Slovene feminine a-stem nouns with long mixed 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 == "Template" then stem = "-" else error("1st parameter (stem) has not been specified.") end end local stem_noending = stem .. "ev" stem = stem .. "v" data.info = "feminine, v-stem" table.insert(data.categories, "Slovene feminine v-stem nouns") -- 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 == "Template" then stem = "-" else error("1st parameter (stem) has not been specified.") end end local stem_noending = make_endingless_stem(stem) data.info = "feminine, i-stem" table.insert(data.categories, "Slovene feminine i-stem nouns") -- 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, mixed 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 == "Template" then stem = "-" else error("1st parameter (stem) has not been specified.") end end local stem_noending = make_endingless_stem(stem) local stem_noaccents = require("Module:sl-common").remove_accents(stem) stem_dat_loc_sg = stem_dat_loc_sg or stem data.info = "feminine, i-stem, long mixed accent" table.insert(data.categories, "Slovene feminine i-stem nouns") table.insert(data.categories, "Slovene feminine i-stem nouns with long mixed 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 == "Template" then stem = "-" else error("1st parameter (stem) has not been specified.") end end local stem_noending = make_endingless_stem(stem) -- Is this a hard stem or a soft stem? local oe = "o" data.info = "neuter" if require("Module:sl-common").is_soft(stem) then oe = "e" data.info = data.info .. ", soft" table.insert(data.categories, "Slovene neuter soft o-stem nouns") else data.info = data.info .. ", hard" table.insert(data.categories, "Slovene neuter hard o-stem nouns") 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

return export