Module:sl-adjectives

local export = {}

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

-- Within this module, inflections are the functions that do the actual inflecting -- by creating the forms of an adjective. They are defined further down. local inflections = {}

-- The main entry point. -- This is the only function that can be invoked from a template. function export.show(frame) PAGENAME = mw.title.getCurrentTitle.text FULLPAGENAME = mw.title.getCurrentTitle.prefixedText NAMESPACE = mw.title.getCurrentTitle.nsText local infl_type = frame.args[1] or error("Inflection type has not been specified.") local args = frame:getParent.args local data = {forms = {}, info = nil, categories = {}} if inflections[infl_type] then inflections[infl_type](args, data) else error("Unknown inflection type '" .. infl_type .. "'") end return make_table(data) end

-- Hard stem adjective inflections["regular"] = function(args, data) local stem = args[1]; if not stem or stem == "" then if NAMESPACE == "Template" then stem = "-" else error("1st parameter (stem) has not been specified.") end end local final = args[2]; if final == "" then final = nil end local def = args["def"] -- Create the full stem, which is used when endings are added local full_stem = stem if final then full_stem = full_stem .. final else full_stem = make_long(full_stem) end -- If the given stem doesn't contain any accent marks, flag the entry for attention if not require("Module:sl-common").has_accents(full_stem) then table.insert(data.categories, "Requests for accents in Slovene adjective entries") end

-- Is this a hard stem or a soft stem? local oe = "o" data.info = "hard" if require("Module:sl-common").is_soft(full_stem) then oe = "e" data.info = "soft" end -- Masculine singular if def == "1" then data.forms["nom_sg_m"] = {full_stem .. "i"} elseif def == "0" then data.forms["nom_sg_m"] = {stem .. (final and "e" .. final or "")} else data.forms["nom_sg_m"] = {stem .. (final and "e" .. final or "")} data.forms["nom_sg_m_def"] = {full_stem .. "i"} end -- acc_sg_m depends on animacy data.forms["gen_sg_m"] = {full_stem .. "ega"} data.forms["dat_sg_m"] = {full_stem .. "emu"} data.forms["loc_sg_m"] = {full_stem .. "em"} data.forms["ins_sg_m"] = {full_stem .. "im"} -- Feminine singular data.forms["nom_sg_f"] = {full_stem .. "a"} data.forms["acc_sg_f"] = {full_stem .. "o"} data.forms["gen_sg_f"] = {full_stem .. "e"} data.forms["dat_sg_f"] = {full_stem .. "i"} data.forms["loc_sg_f"] = {full_stem .. "i"} data.forms["ins_sg_f"] = {full_stem .. "o"} -- Neuter singular data.forms["nom_sg_n"] = {full_stem .. oe} data.forms["acc_sg_n"] = {full_stem .. oe} data.forms["gen_sg_n"] = {full_stem .. "ega"} data.forms["dat_sg_n"] = {full_stem .. "emu"} data.forms["loc_sg_n"] = {full_stem .. "em"} data.forms["ins_sg_n"] = {full_stem .. "im"} -- Masculine dual data.forms["nom_du_m"] = {full_stem .. "a"} data.forms["acc_du_m"] = {full_stem .. "a"} data.forms["gen_du_m"] = {full_stem .. "ih"} data.forms["dat_du_m"] = {full_stem .. "ima"} data.forms["loc_du_m"] = {full_stem .. "ih"} data.forms["ins_du_m"] = {full_stem .. "ima"} -- Feminine dual data.forms["nom_du_f"] = {full_stem .. "i"} data.forms["acc_du_f"] = {full_stem .. "i"} data.forms["gen_du_f"] = {full_stem .. "ih"} data.forms["dat_du_f"] = {full_stem .. "ima"} data.forms["loc_du_f"] = {full_stem .. "ih"} data.forms["ins_du_f"] = {full_stem .. "ima"} -- Neuter dual data.forms["nom_du_n"] = {full_stem .. "i"} data.forms["acc_du_n"] = {full_stem .. "i"} data.forms["gen_du_n"] = {full_stem .. "ih"} data.forms["dat_du_n"] = {full_stem .. "ima"} data.forms["loc_du_n"] = {full_stem .. "ih"} data.forms["ins_du_n"] = {full_stem .. "ima"} -- Masculine plural data.forms["nom_pl_m"] = {full_stem .. "i"} data.forms["acc_pl_m"] = {full_stem .. "e"} data.forms["gen_pl_m"] = {full_stem .. "ih"} data.forms["dat_pl_m"] = {full_stem .. "im"} data.forms["loc_pl_m"] = {full_stem .. "ih"} data.forms["ins_pl_m"] = {full_stem .. "imi"} -- Feminine plural data.forms["nom_pl_f"] = {full_stem .. "e"} data.forms["acc_pl_f"] = {full_stem .. "e"} data.forms["gen_pl_f"] = {full_stem .. "ih"} data.forms["dat_pl_f"] = {full_stem .. "im"} data.forms["loc_pl_f"] = {full_stem .. "ih"} data.forms["ins_pl_f"] = {full_stem .. "imi"} -- Neuter plural data.forms["nom_pl_n"] = {full_stem .. "a"} data.forms["acc_pl_n"] = {full_stem .. "a"} data.forms["gen_pl_n"] = {full_stem .. "ih"} data.forms["dat_pl_n"] = {full_stem .. "im"} data.forms["loc_pl_n"] = {full_stem .. "ih"} data.forms["ins_pl_n"] = {full_stem .. "imi"} end

function make_long(stem) local vowel_repl = { ["à"] = "á", ["è"] = "ê", ["ì"] = "í", ["ò"] = "ô", ["ù"] = "ú"} function repl(vowel, rest) return (vowel_repl[vowel] or vowel) .. rest end return mw.ustring.gsub(stem, "([àèìòù])([^aeiouàèìòùáéíóúêô]+)$", repl) end

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

return export