local export = {}
local lang = require("Module:languages").getByCode("wmw")
local plural_classes = {
= "c2", = "c2", = "c4", = "c8", = "c10", = "c6",
= "c6", = "c6", = "c10"}
local plural_rules = {
= { = {"mwi", "we", 4}, = {"mwa", "wa", 4}, = {"mu", "wa", 3}, = { "n", "wa", 2}},
= { = { "", "wa", 1}},
= { = {"mwi", "mi", 4}, = {"mw", "my", 3}, = {"m", "mi", 2}, = { "n", "mi", 2}},
= { = {"", "ma", 1}},
= { = {"ki", "vi", 3}, = {"ch", "vy", 3}},
= { = {"", "", 1}},
= { = {"", "ma", 1}},
= { = { "lu", "ma", 3}},
= { = { "", "ma", 1}},
}
function export.noun(frame)
local params = {
= {required=true},
= {},
= {},
= {alias_of = "head"}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "nouns", categories = {}, heads = {args}, genders = mw.text.split(args, "%/"), inflections = {}}
table.insert(data.categories, lang:getCanonicalName() .. " class " .. data.genders .. " nouns")
local singular = args and require("Module:links").remove_links(args) or mw.title.getCurrentTitle().text
local inflection = nil
if not args then
inflection = export.generate_plural(singular, args)
else
if (args ~= "-") then
inflection = args
end
end
local accel = {form = "p"}
if (plural_classes]) then
accel.gender = plural_classes]
end
if (inflection) then
table.insert(data.inflections, {label = "plural", accel = accel, inflection})
end
return require("Module:headword").full_headword(data)
end
function startswith(test_string, start)
return mw.ustring.sub(mw.ustring.lower(test_string),1,mw.ustring.len(start))==mw.ustring.lower(start)
end
function match_case(string1, string2)
c1 = mw.ustring.sub(string1, 1, 1)
c2 = mw.ustring.sub(string2, 1, 1)
if (mw.ustring.lower(c1) == c1) then
return mw.ustring.lower(c2) .. mw.ustring.sub(string2, 2)
end
return mw.ustring.upper(c2).. mw.ustring.sub(string2, 2)
end
function export.generate_plural(singular, class)
if (plural_rules) then
for k,v in ipairs(plural_rules) do
if startswith(singular, v) then
return match_case(singular, v..mw.ustring.sub(singular, v))
end
end
end
end
return export