Module:dum-adjectives
Appearance
- The following documentation is located at Module:dum-adjectives/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
local m_links = require("Module:links")
local m_common = require("Module:dum-common")
local lang = require("Module:languages").getByCode("dum")
local export = {}
function export.show(frame)
local params = {
[1] = {required = true, default = "{{{1}}}"},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {forms = {}, info = "adjective", categories = {}}
local stem = mw.ustring.gsub(args[1], "([^aeiouâêîôûāēōë])e$", "%1")
data.forms["m_nom_indf"] = {m_common.devoiced(m_common.checked(args[1]))}
data.forms["m_acc"] = {stem .. "en"}
data.forms["m_dat"] = {stem .. "en"}
data.forms["n_nom_indf"] = {m_common.devoiced(m_common.checked(args[1]))}
data.forms["n_acc_indf"] = {m_common.devoiced(m_common.checked(args[1]))}
data.forms["n_dat"] = {stem .. "en"}
data.forms["p_dat"] = {stem .. "en"}
if mw.ustring.find(args[1], "[aeiouâêîôûāēōë][^aeiouâêîôûāēōë]+e[lnr]$") then
data.forms["m_nom_defn"] = {stem, stem .. "e"}
data.forms["f_nom"] = {stem, stem .. "e"}
data.forms["f_acc"] = {stem, stem .. "e"}
data.forms["n_nom_defn"] = {stem, stem .. "e"}
data.forms["n_acc_defn"] = {stem, stem .. "e"}
data.forms["p_nom"] = {stem, stem .. "e"}
data.forms["p_acc"] = {stem, stem .. "e"}
else
data.forms["m_nom_defn"] = {stem .. "e"}
data.forms["f_nom"] = {stem .. "e"}
data.forms["f_acc"] = {stem .. "e"}
data.forms["n_nom_defn"] = {stem .. "e"}
data.forms["n_acc_defn"] = {stem .. "e"}
data.forms["p_nom"] = {stem .. "e"}
data.forms["p_acc"] = {stem .. "e"}
end
if mw.ustring.find(args[1], "[^aeiouâêîôûāēōë]e$") then
data.forms["m_gen_indf"] = {args[1] .. "s"}
data.forms["n_gen_indf"] = {args[1] .. "s"}
data.forms["m_gen_defn"] = {args[1] .. "s", args[1] .. "n"}
data.forms["n_gen_defn"] = {args[1] .. "s", args[1] .. "n"}
elseif mw.ustring.find(stem, "s$") or mw.ustring.find(stem, "sch$") then
data.forms["m_gen_indf"] = {m_common.checked(stem)}
data.forms["n_gen_indf"] = {m_common.checked(stem)}
data.forms["m_gen_defn"] = {m_common.checked(stem), stem .. "en"}
data.forms["n_gen_defn"] = {m_common.checked(stem), stem .. "en"}
else
data.forms["m_gen_indf"] = {m_common.devoiced(m_common.checked(stem)) .. "s"}
data.forms["n_gen_indf"] = {m_common.devoiced(m_common.checked(stem)) .. "s"}
data.forms["m_gen_defn"] = {m_common.devoiced(m_common.checked(stem)) .. "s", stem .. "en"}
data.forms["n_gen_defn"] = {m_common.devoiced(m_common.checked(stem)) .. "s", stem .. "en"}
end
if mw.ustring.find(stem, "[lnr]$") then
data.forms["f_gen"] = {m_common.checked(args[1]) .. "re"}
data.forms["f_dat"] = {m_common.checked(args[1]) .. "re"}
data.forms["p_gen"] = {m_common.checked(args[1]) .. "re"}
else
data.forms["f_gen"] = {stem .. "er"}
data.forms["f_dat"] = {stem .. "er"}
data.forms["p_gen"] = {stem .. "er"}
end
return make_table(data)
end
-- Make the table
function make_table(data)
local function repl(param)
if param == "info" then
return mw.getContentLanguage():ucfirst(data.info or "")
end
local form = data.forms[param]
if not form or #form == 0 then
return "—"
end
local ret = {}
for key, subform in ipairs(form) do
table.insert(ret, m_links.full_link({lang = lang, alt = subform}))
end
return table.concat(ret, ", ")
end
local names = {
["m"] = "masculine",
["f"] = "feminine",
["n"] = "neuter",
["nom"] = "nominative",
["acc"] = "accusative",
["gen"] = "genitive",
["dat"] = "dative",
["s"] = "singular",
["p"] = "plural",
["indf"] = "indefinite",
["defn"] = "definite",
}
local cases = {"nom", "acc", "gen", "dat"}
local genders = {"m", "f", "n", "p"}
local defns = {"indf", "defn"}
local wikicode = {}
table.insert(wikicode, "{| class=\"inflection-table vsSwitcher\" data-toggle-category=\"inflection\" style=\"width: 100%; border: 1px solid var(--wikt-palette-indigo, #aaaaee);\" cellspacing=\"1\" cellpadding=\"3\"")
table.insert(wikicode, "|- style=\"background: var(--wikt-palette-indigo, #aaaaee);\"")
table.insert(wikicode, "! class=\"vsToggleElement\" style=\"text-align: left\" colspan=\"" .. tostring(#genders + 2) .. "\" | {{{info}}}")
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-indigo, #aaaaee);\"")
table.insert(wikicode, "| style=\"background: var(--wikt-palette-lightindigo, #e9e9ff)\" colspan=\"2\" |")
for _, g in ipairs(genders) do
table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo, #aaaaee)\" | " .. mw.getContentLanguage():ucfirst(names[g]))
end
for _, case in ipairs(cases) do
if case == "nom" or case == "gen" then
for i, d in ipairs(defns) do
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-lightindigo, #e9e9ff)\"")
if i == 1 then
table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo, #aaaaee)\" rowspan=\"" .. tostring(#defns) .. "\" | " .. mw.getContentLanguage():ucfirst(names[case]))
end
table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo, #aaaaee)\" | " .. mw.getContentLanguage():ucfirst(names[d]))
for _, g in ipairs(genders) do
if g == "m" or g == "n" then
table.insert(wikicode, "| {{{" .. g .. "_" .. case .. "_" .. d .. "}}}")
elseif i == 1 then
table.insert(wikicode, "| rowspan=\"" .. tostring(#defns) .. " | {{{" .. g .. "_" .. case .. "}}}")
end
end
end
elseif case == "acc" then
for i, d in ipairs(defns) do
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-lightindigo, #e9e9ff)\"")
if i == 1 then
table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo, #aaaaee)\" rowspan=\"" .. tostring(#defns) .. "\" | " .. mw.getContentLanguage():ucfirst(names[case]))
end
table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo, #aaaaee)\" | " .. mw.getContentLanguage():ucfirst(names[d]))
for _, g in ipairs(genders) do
if g == "n" then
table.insert(wikicode, "| {{{" .. g .. "_" .. case .. "_" .. d .. "}}}")
elseif i == 1 then
table.insert(wikicode, "| rowspan=\"" .. tostring(#defns) .. " | {{{" .. g .. "_" .. case .. "}}}")
end
end
end
else
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: var(--wikt-palette-lightindigo, #e9e9ff)\"")
table.insert(wikicode, "! style=\"background: var(--wikt-palette-indigo, #aaaaee);\" colspan=\"2\" | " .. mw.getContentLanguage():ucfirst(names[case]))
for _, g in ipairs(genders) do
table.insert(wikicode, "| {{{" .. g .. "_" .. case .. "}}}")
end
end
end
table.insert(wikicode, "|}")
wikicode = table.concat(wikicode, "\n")
return (mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. require("Module:utilities").format_categories(data.categories, lang)
end
return export