Module:snon-headword: Difference between revisions

No edit summary
No edit summary
Line 74: Line 74:
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------


local allowed_genders = m_table.listToSet(
local allowed_genders = {
    {"m", "f", "mf", "mfbysense", "mfequiv", "gneut", "n", "m-p", "f-p", "mf-p", "mfbysense-p", "mfequiv-p", "gneut-p", "n-p", "?", "?-p"}
"m", "f", "mf", "mfbysense", "mfequiv", "gneut", "n", "m-p",
)
"f-p", "mf-p", "mfbysense-p", "mfequiv-p", "gneut-p", "n-p",
 
"?", "?-p"
local function validate_genders(genders)
}
for _, g in ipairs(genders) do
if type(g) == "table" then
g = g.spec
end
if not allowed_genders[g] then
error("Unrecognized gender: " .. g)
end
end
end


local function do_noun(args, data, is_proper)
local function do_noun(args, data, is_proper)
Line 93: Line 84:
local category_pos = m_en_util.singularize(data.pos_category)
local category_pos = m_en_util.singularize(data.pos_category)


validate_genders(args[1])
data.genders = args[1]
data.genders = args[1]
-- Check for specific genders and pluralia tantum.
-- Check for specific genders and pluralia tantum.
Line 148: Line 138:
end
end
end
end
 
if args.mut then
local mutation = {
["r"] = "radical", ["l"] = "lenite", ["e"] = "eclipse"
}
table.insert(data.inflections, {label = mutation[args.mut]})
end
if is_plurale_tantum then
if is_plurale_tantum then
-- both singular and plural
-- both singular and plural
Line 215: Line 213:
local function get_noun_params(is_proper)
local function get_noun_params(is_proper)
return {
return {
[1] = {list = "g", disallow_holes = true, required = not is_proper, default = "?", type = "genders", flatten = true},
[1] = {list = "g", disallow_holes = true, required = not is_proper, default = "?", type = "genders", flatten = true, set = allowed_genders},
[2] = {list = "pl", disallow_holes = true},
[2] = {list = "pl", disallow_holes = true},
["mut"] = {set = {"r", "l", "e"}},
}
}
end
end