For use in {{ln-noun}}
.
local export = {}
local lang = require("Module:languages").getByCode("ln")
local plural_classes = {
= "c2", = "c4", = "c8", = "c10",
= "c10", = "c6", = "c6", = "c2", = "c6", = "c6"}
local plural_rules = {
= { = {"mo", "ba", 3}, = {"mw", "b", 3}, = {"a", "b", 2}, = {"", "ba", 1}},
= { = {"mo", "mi", 3}, = {"mw", "my", 3}},
= { = {"li", "ma", 3}},
= { = {"e", "bi", 2}},
= { = { "", "", 1}},
= { = { "a", "ma", 2}, = { "", "ma", 1}},
= { = { "a", "ba", 2}, = { "", "ba", 1}},
= { = {"lol", "nd", 4}, = {"lob", "mb", 4}, = {"lop", "mp", 4}, = {"lom", "m", 4}, = {"lon", "n", 4}, = {"lo", "n", 3},},
= { = {"lo", "ma", 3}},
= { = {"bo", "ma", 3}, = {"bw", "m", 3}}
}
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")
if args ~= "-" and plural_classes] then
local infl_plural = {label = "plural", accel = {form = "p", gender = plural_classes]}, request = true}
-- If no plural was provided, generate one
if not args then
local singular = args and require("Module:links").remove_links(args) or mw.title.getCurrentTitle().text
args = export.generate_plural(singular, args)
end
if args then
table.insert(infl_plural, {term = args, genders = {plural_classes]}})
end
table.insert(data.inflections, infl_plural)
-- colloquial plural for class 9
if args == "9" or args == "9/6" then
local infl_coll_plural = {label = "colloquial plural", accel = {form = "p", gender = "c2"}, request = true}
local singular = args and require("Module:links").remove_links(args) or mw.title.getCurrentTitle().text
local coll_plural = export.generate_plural(singular, "9/2")
table.insert(infl_coll_plural, {term = coll_plural, genders = {"c2"}})
table.insert(data.inflections, infl_coll_plural)
end
end
return require("Module:headword").full_headword(data)
end
function match_case(string1, string2)
local c1 = mw.ustring.sub(string1, 1, 1)
local c2 = mw.ustring.sub(string2, 1, 1)
if (mw.ustring.lower(c1) == c1) then
return mw.ustring.lower(c2) .. mw.ustring.sub(string2, 2)
else
return mw.ustring.upper(c2) .. mw.ustring.sub(string2, 2)
end
end
function export.generate_plural(singular, class)
if plural_rules then
for k, v in ipairs(plural_rules) do
if mw.ustring.find(mw.ustring.lower(singular), "^" .. v) then
return match_case(singular, v .. mw.ustring.sub(singular, v))
end
end
end
end
function export.verb(frame)
local params = {
= {},
= {},
= {alias_of = "head"}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local head = args or mw.title.getCurrentTitle().text
local inf = args or "ko"..head
local data = {lang = lang,
pos_category = "verbs",
categories = {},
heads = {"-"..head},
inflections = {{label="infinitive", accel = {form = "infinitive"}, inf}}}
return require("Module:headword").full_headword(data)
end
return export