Module:li-adj

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

local lang = require("Module:languages").getByCode("li") local export = {}

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

-- 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] == nil and "regular" or frame.args[1] if not inflections[infl_type] then error("Unknown inflection type '" .. infl_type .. "'") end local data = {forms = {}, categories = {}} data.info = "" local args = require("Module:parameters").process(frame:getParent.args, inflections[infl_type].params) -- Generate the forms inflections[infl_type].func(args, data) return make_table(data) end

inflections["regular"] = { params = { [1] = {},		[2] = {},		["doubled"] = {} },	func = function(args, data) local base = mw.title.getCurrentTitle.nsText == "Template" and "-" or mw.title.getCurrentTitle.text -- Final consonant is doubled in certain cases to show a short vowel (like English and Dutch) -- If the stem ends in -e, don't add another one local doubled = args["doubled"] ~= "" and args["doubled"] or (base:find("e$") and base:sub(1, -2) or base) data.forms["nom_sg_m"] = doubled .. "e" data.forms["nom_pl_m"] = base data.forms["nom_sg_f"] = base data.forms["nom_pl_f"] = base data.forms["nom_sg_n"] = base data.forms["nom_pl_n"] = base data.forms["gen_sg_m"] = doubled:sub(-1) == "s" and doubled .. "es" or doubled .. "s" data.forms["gen_pl_m"] = doubled .. "er" data.forms["gen_sg_f"] = doubled .. "er" data.forms["gen_pl_f"] = doubled .. "er" data.forms["gen_sg_n"] = doubled:sub(-1) == "s" and doubled .. "es" or doubled .. "s" data.forms["gen_pl_n"] = doubled .. "er" data.forms["loc_sg_m"] = doubled .. "es" data.forms["loc_pl_m"] = doubled .. "es" data.forms["loc_sg_f"] = doubled .. "es" data.forms["loc_pl_f"] = doubled .. "es" data.forms["loc_sg_n"] = doubled .. "es" data.forms["loc_pl_n"] = doubled .. "es" data.forms["voc_all"] = base data.forms["dat_sg_m"] = doubled .. "e" data.forms["dat_pl_m"] = doubled .. "en" data.forms["dat_sg_f"] = doubled .. "er" data.forms["dat_pl_f"] = doubled .. "en" data.forms["dat_sg_n"] = base data.forms["dat_pl_n"] = doubled .. "en" data.forms["acc_sg_m"] = doubled .. "e" data.forms["acc_pl_m"] = doubled .. "en" data.forms["acc_sg_f"] = base data.forms["acc_pl_f"] = base data.forms["acc_sg_n"] = base data.forms["acc_pl_n"] = doubled .. "en" end }

inflections["irregular"] = { params = { [1] = {},		[2] = {}		},	func = function(args, data) local base = args[2] or (mw.title.getCurrentTitle.nsText == "Template" and "good" or mw.title.getCurrentTitle.text) if irregular[base] then irregular[base](data) else error("Unknown irregular adjective '" .. base .. "'.") end end }

irregular["good"] = function(data) table.insert(data.categories, "Limburgish irregular adjectives") data.info = " (irregular)"

data.forms["nom_sg_m"] = "gooje" data.forms["nom_pl_m"] = "gooj" data.forms["nom_sg_f"] = "gooj" data.forms["nom_pl_f"] = "gooj" data.forms["nom_sg_n"] = "good" data.forms["nom_pl_n"] = "gooj" data.forms["gen_sg_m"] = "goods" data.forms["gen_pl_m"] = "goojer" data.forms["gen_sg_f"] = "goojer" data.forms["gen_pl_f"] = "goojer" data.forms["gen_sg_n"] = "goods" data.forms["gen_pl_n"] = "goojer" data.forms["loc_sg_m"] = "goojes" data.forms["loc_pl_m"] = "gooje" data.forms["loc_sg_f"] = "goojes" data.forms["loc_pl_f"] = "gooje" data.forms["loc_sg_n"] = "goojes" data.forms["loc_pl_n"] = "gooje" data.forms["voc_all"] = "gooj" data.forms["dat_sg_m"] = "gooje" data.forms["dat_pl_m"] = "goojen" data.forms["dat_sg_f"] = "goojer" data.forms["dat_pl_f"] = "goojen" data.forms["dat_sg_n"] = "good" data.forms["dat_pl_n"] = "goojen" data.forms["acc_sg_m"] = "gooje" data.forms["acc_pl_m"] = "goojen" data.forms["acc_sg_f"] = "good" data.forms["acc_pl_f"] = "gooj" data.forms["acc_sg_n"] = "good" data.forms["acc_pl_n"] = "goojen" end

-- Make the table function make_table(data) local function show_form(form) if not form then return "&mdash;" end local ret = {} table.insert(ret, m_links.full_link({lang = lang, term = form})) 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.info else return show_form(data.forms[param]) end end local wikicode = [=[ Declension of return (mw.ustring.gsub(wikicode, "", repl)) .. m_utils.format_categories(data.categories, lang) end

return export