-- Prevent substitution.
if mw.isSubsting() then
return require("Module:unsubst")
end
local export = {}
local m_headword = require("Module:headword")
local insert = table.insert
local list = {list = true}
local pos_functions = {}
pos_functions = {
params = function()
return pairs{
= {alias_of = "cl"},
= {sublist = "/", default = "?"},
= list,
= list,
= list,
= list,
= list,
}
end,
func = function(lang, args, data)
local cl = args.cl
for i, g in ipairs(cl) do
cl = "c" .. g
end
local cl_n, sg_only, pl_only = #cl
cl, sg_only = cl:gsub("-s$", "")
sg_only = sg_only > 0 and true or false
cl, pl_only = cl:gsub("-p$", "")
pl_only = pl_only > 0 and true or false
if pl_only and sg_only then
error("Cannot specify both plural only and singular only.")
end
local inflections, gen, erg, ins, sg, pl = {}, args.gen, args.erg, args.ins, args.sg, args.pl
if pl_only then
insert(inflections, {label = "plural only"})
insert(data.categories, lang:getCanonicalName() .. " pluralia tantum")
elseif sg_only then
insert(inflections, {label = "singular only"})
insert(data.categories, lang:getCanonicalName() .. " singularia tantum")
end
if gen then
gen.label = "genitive"
insert(inflections, gen)
end
if erg then
erg.label = "ergative"
insert(inflections, erg)
end
if ins then
ins.label = "instrumental"
insert(inflections, ins)
end
if sg then
if not pl_only then
error("Cannot specify singulars unless the lemma is plural.")
end
sg.label = "singular"
insert(inflections, sg)
end
if pl then
if pl_only then
error("Cannot specify plurals when the lemma is plural.")
end
pl.label = "plural"
insert(inflections, pl)
end
data.inflections = inflections
end,
}
pos_functions = pos_functions
function export.show(frame)
local poscat = frame.args or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local params = {
= {alias_of = "head", list = false},
= list,
= list_allow_holes,
= list_allow_holes,
= true,
}
local pos_data, pos_func = pos_functions
if pos_data then
local pos_params = pos_data.params
if pos_params then
for key, val in pos_params() do
params = val
end
end
pos_func = pos_data.func
end
local args = require("Module:parameters").process(frame:getParent().args, params)
local lang = require("Module:languages").getByCode(frame.args, true)
local data = {
lang = lang,
heads = args,
genders = args,
translits = args,
transcriptions = args,
inflections = inflections,
pos_category = m_headword.pluralize_pos(poscat),
categories = {}
}
if pos_func then
pos_func(lang, args, data)
end
return m_headword.full_headword(data)
end
return export