A modult a Modul:sn-headword/doc lapon tudod dokumentálni
local export = {}
local lang = require("Module:languages").getByCode("sn")
local plural_classes = {
= "c2", = "c2", = "c4", = "c8", = "c10", = "c10", = "c6",
= "c13", = "c6", = "c6", = "c6", = "c6", = "c6"}
local plural_rules = {
= { = {"mw", "v", 3}, = {"mu", "va", 3}},
= { = {"", "va", 1}},
= { = {"mu", "mi", 3}, = {"mw", "mw", 3}},
= { = {"i", "ma", 2}, = {"zi", "me", 3}, = {"dz", "mats", 3}, = {"bv", "mapf", 3}, = {"bh", "mabh", 3}, = {"b", "map", 2}, = {"g", "mak", 2}, = {"dh", "madh", 3}, = {"d", "mat", 2}, = {"j", "mach", 2}, = {"", "ma", 1}},
= { = {"ch", "zv", 3}},
= { = { "", "", 1}},
= { = { "", "ma", 1}},
= { = {"ruk", "h", 4}, = {"ru", "", 3}, = {"rw", "", 3}},
= { = { "", "ma", 1}},
= { = { "", "ma", 1}}
}
function export.noun(frame)
local params = {
= {},
= {},
= {}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local categories = {}
local head
if not args then
args = mw.title.getCurrentTitle().subpageText
head = mw.title.getCurrentTitle().subpageText:gsub("^-", "") .. "<sup title=\"tones missing\">?</sup>"
table.insert(categories, "Requests for tone in " .. lang:getCanonicalName() .. " noun entries")
end
local class
if args then
class = mw.text.split(args, "%/")
else
class = "?"
end
local data = {lang = lang, pos_category = "nouns", categories = categories, heads = {head or args}, genders = {"c" .. class}, inflections = {}}
if class ~= "?" then
table.insert(data.categories, lang:getCanonicalName() .. " class " .. class .. " nouns")
end
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
table.insert(infl_plural, {term = args, genders = {plural_classes]}})
table.insert(data.inflections, infl_plural)
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
return export