Module:nd-adjectives
Jump to navigation
Jump to search
- The following documentation is located at Module:nd-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("nd")
local export = {}
function export.adjective(frame)
local params = {
[1] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {forms = {}, info = "adjective 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() .. " adjective entries")
end
local base = mw.title.getCurrentTitle().subpageText
data.forms["mod_1sg"] = {"engim" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base}
data.forms["mod_2sg"] = {"om" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base}
data.forms["mod_1pl"] = {"esiba" .. base}
data.forms["mod_2pl"] = {"eliba" .. base}
data.forms["mod_c1"] = {"om" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base}
data.forms["mod_c2"] = {"aba" .. base}
data.forms["mod_c3"] = {"om" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base}
data.forms["mod_c4"] = {"emi" .. base}
data.forms["mod_c5"] = {"eli" .. base}
data.forms["mod_c6"] = {"ama" .. base}
data.forms["mod_c7"] = {"esi" .. base}
data.forms["mod_c8"] = {"ezi" .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. (mw.ustring.find(base, "^[ptk]h") and mw.ustring.gsub(base, "^([ptk])h", "%1") or base)}
data.forms["mod_c9"] = {"e" .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. (mw.ustring.find(base, "^[ptk]h") and mw.ustring.gsub(base, "^([ptk])h", "%1") or base)}
data.forms["mod_c10"] = {"ezi" .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. (mw.ustring.find(base, "^[ptk]h") and mw.ustring.gsub(base, "^([ptk])h", "%1") or base)}
data.forms["mod_c11"] = {"olu" .. base}
data.forms["mod_c14"] = {"obu" .. base}
data.forms["mod_c15"] = {"oku" .. base}
data.forms["mod_c17"] = {"oku" .. base}
data.forms["cop_1sg"] = {"ngim" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base}
data.forms["cop_2sg"] = {"um" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base}
data.forms["cop_1pl"] = {"siba" .. base}
data.forms["cop_2pl"] = {"liba" .. base}
data.forms["cop_c1"] = {"m" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base}
data.forms["cop_c2"] = {"ba" .. base}
data.forms["cop_c3"] = {"m" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base}
data.forms["cop_c4"] = {"mi" .. base}
data.forms["cop_c5"] = {"li" .. base}
data.forms["cop_c6"] = {"ma" .. base}
data.forms["cop_c7"] = {"si" .. base}
data.forms["cop_c8"] = {"zi" .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. (mw.ustring.find(base, "^[ptk]h") and mw.ustring.gsub(base, "^([ptk])h", "%1") or base)}
data.forms["cop_c9"] = {"i" .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. (mw.ustring.find(base, "^[ptk]h") and mw.ustring.gsub(base, "^([ptk])h", "%1") or base)}
data.forms["cop_c10"] = {"zi" .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. (mw.ustring.find(base, "^[ptk]h") and mw.ustring.gsub(base, "^([ptk])h", "%1") or base)}
data.forms["cop_c11"] = {"lu" .. 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
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"] = {"eli" .. 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_c11"] = {"olu" .. 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"] = {"li" .. 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_c11"] = {"lu" .. 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",
["c11"] = "class 11",
["c14"] = "class 14",
["c15"] = "class 15",
["c17"] = "class 17",
}
local classes = {"c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11", "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