Module:ss-adjectives

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

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

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"] = {"lengim" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base} data.forms["mod_2sg"] = {"lom" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base} data.forms["mod_1pl"] = {"lesiba" .. base} data.forms["mod_2pl"] = {"leniba" .. base} data.forms["mod_c1"] = {"lom" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base} data.forms["mod_c2"] = {"laba" .. base} data.forms["mod_c3"] = {"lom" .. (mw.ustring.find(base, "^[^aeiou]+[aeiou]$") and "u" or "") .. base} data.forms["mod_c4"] = {"lemi" .. base} data.forms["mod_c5"] = {"leli" .. base} data.forms["mod_c6"] = {"lama" .. base} data.forms["mod_c7"] = {"lesi" .. base} data.forms["mod_c8"] = {"leti" .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. base} data.forms["mod_c9"] = {"le"   .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. base} data.forms["mod_c10"] = {"leti" .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. base} data.forms["mod_c11"] = {"lolu" .. base} data.forms["mod_c14"] = {"lobu" .. base} data.forms["mod_c15"] = {"loku" .. base} data.forms["mod_c17"] = {"loku" .. 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"] = {"niba" .. 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"] = {"ti" .. base} data.forms["cop_c8"] = {"ti" .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. base} data.forms["cop_c9"] = {"i"  .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. base} data.forms["cop_c10"] = {"ti" .. (mw.ustring.find(base, "^[bfp]") and "m" or mw.ustring.find(base, "^n") and "" or "n") .. 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"] = {"lengi" .. base} data.forms["mod_2sg"] = {"lo" .. base} data.forms["mod_1pl"] = {"lesi" .. base} data.forms["mod_2pl"] = {"leni" .. base} data.forms["mod_c1"] = {"lo" .. base} data.forms["mod_c2"] = {"laba" .. base} data.forms["mod_c3"] = {"lo" .. base} data.forms["mod_c4"] = {"le" .. base} data.forms["mod_c5"] = {"leli" .. base} data.forms["mod_c6"] = {"la" .. base} data.forms["mod_c7"] = {"lesi" .. base} data.forms["mod_c8"] = {"leti" .. base} data.forms["mod_c9"] = {"le" .. base} data.forms["mod_c10"] = {"leti" .. base} data.forms["mod_c11"] = {"lolu" .. base} data.forms["mod_c14"] = {"lobu" .. base} data.forms["mod_c15"] = {"loku" .. base} data.forms["mod_c17"] = {"loku" .. 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"] = {"ti" .. base} data.forms["cop_c9"] = {"i" .. base} data.forms["cop_c10"] = {"ti" .. 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 "&mdash;" 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\" | ") 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, "| ") end end table.insert(wikicode, "|}") wikicode = table.concat(wikicode, "\n") return mw.ustring.gsub(wikicode, "", repl) end

return export