Module:nr-adjectives
Appearance
- The following documentation is located at Module:nr-adjectives/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local lang = require("Module:languages").getByCode("nr")
local export = {}
function export.relative(frame)
local params = {
[1] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {forms = {}, info = "relative concord", categories = {}}
if args[1] == "L" or args[1] == "H" or args[1] == "LH" or args[1] == "HH" or args[1] == "HHH" then
data.info = data.info .. ", tone " .. args[1]
table.insert(data.categories, lang:getCanonicalName() .. " adjectives with tone " .. args[1])
elseif args[1] then
error("The tone must be \"L\", \"H\", \"LH\", \"HH\" or \"HHH\".")
else
table.insert(data.categories, "Requests for tone in " .. lang:getCanonicalName() .. " relative entries")
end
local base = mw.title.getCurrentTitle().subpageText
data.forms["mod_1sg"] = {"engi" .. base}
data.forms["mod_2sg"] = {"o" .. base}
data.forms["mod_1pl"] = {"esi" .. base}
data.forms["mod_2pl"] = {"eni" .. base}
data.forms["mod_c1"] = {"o" .. base}
data.forms["mod_c2"] = {"aba" .. base}
data.forms["mod_c3"] = {"o" .. base}
data.forms["mod_c4"] = {"e" .. base}
data.forms["mod_c5"] = {"eli" .. base}
data.forms["mod_c6"] = {"a" .. base}
data.forms["mod_c7"] = {"esi" .. base}
data.forms["mod_c8"] = {"ezi" .. base}
data.forms["mod_c9"] = {"e" .. base}
data.forms["mod_c10"] = {"ezi" .. base}
data.forms["mod_c14"] = {"obu" .. base}
data.forms["mod_c15"] = {"oku" .. base}
data.forms["mod_c17"] = {"oku" .. base}
data.forms["cop_1sg"] = {"ngi" .. base}
data.forms["cop_2sg"] = {"u" .. base}
data.forms["cop_1pl"] = {"si" .. base}
data.forms["cop_2pl"] = {"ni" .. base}
data.forms["cop_c1"] = {"u" .. base}
data.forms["cop_c2"] = {"ba" .. base}
data.forms["cop_c3"] = {"u" .. base}
data.forms["cop_c4"] = {"i" .. base}
data.forms["cop_c5"] = {"li" .. base}
data.forms["cop_c6"] = {"a" .. base}
data.forms["cop_c7"] = {"si" .. base}
data.forms["cop_c8"] = {"zi" .. base}
data.forms["cop_c9"] = {"i" .. base}
data.forms["cop_c10"] = {"zi" .. base}
data.forms["cop_c14"] = {"bu" .. base}
data.forms["cop_c15"] = {"ku" .. base}
data.forms["cop_c17"] = {"ku" .. base}
return make_table(data) .. m_utilities.format_categories(data.categories, lang)
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, term = subform}))
end
return table.concat(ret, ", ")
end
local names = {
["mod"] = "modifier",
["cop"] = "copulative",
["1sg"] = "1st singular",
["2sg"] = "2nd singular",
["1pl"] = "1st plural",
["2pl"] = "2nd plural",
["c1"] = "class 1",
["c2"] = "class 2",
["c3"] = "class 3",
["c4"] = "class 4",
["c5"] = "class 5",
["c6"] = "class 6",
["c7"] = "class 7",
["c8"] = "class 8",
["c9"] = "class 9",
["c10"] = "class 10",
["c14"] = "class 14",
["c15"] = "class 15",
["c17"] = "class 17",
}
local classes = {"c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c14", "c15", "c17"}
local columns = {"mod"}
if not data.simple then
table.insert(classes, 1, "1sg")
table.insert(classes, 2, "2sg")
table.insert(classes, 3, "1pl")
table.insert(classes, 4, "2pl")
table.insert(columns, "cop")
end
local wikicode = {}
table.insert(wikicode, "{| class=\"wikitable inflection-table vsSwitcher vsToggleCategory-inflection\" style=\"border-style: double; border-width: 3px; margin: 0;\"")
table.insert(wikicode, "|-")
table.insert(wikicode, "! class=\"vsToggleElement\" style=\"background: #CCC; min-width: 20em; text-align: left;\" colspan=\"3\" | {{{info}}}")
table.insert(wikicode, "|- class=\"vsHide\"")
table.insert(wikicode, "| style=\"min-width: 8em;\" |")
for _, col in ipairs(columns) do
table.insert(wikicode, "! style=\"min-width: 12em;\" | " .. mw.getContentLanguage():ucfirst(names[col]))
end
for _, class in ipairs(classes) do
table.insert(wikicode, "|- class=\"vsHide\"")
table.insert(wikicode, "! " .. mw.getContentLanguage():ucfirst(names[class]))
for _, col in ipairs(columns) do
table.insert(wikicode, "| {{{" .. col .. "_" .. class .. "}}}")
end
end
table.insert(wikicode, "|}")
wikicode = table.concat(wikicode, "\n")
return mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)
end
return export