local export = {}
local pos_functions = {}
local lang = require("Module:languages").getByCode("taln")
local langname = lang:getCanonicalName()
local require_when_needed = require("Module:utilities/require when needed")
local m_headword_utilities = require_when_needed("Module:headword utilities")
local force_cat = false
local insert = table.insert
-- The main entry point.
function export.show(frame)
local iparams = {
[1] = {required = true},
}
local iargs = require("Module:parameters").process(frame.args, iparams)
local args = frame:getParent().args
local poscat = iargs[1]
local params = {
["head"] = { list = true, disallow_holes = true },
["tr"] = { list = true, allow_holes = true },
["id"] = {},
["nolinkhead"] = { type = "boolean" },
["pagename"] = {}, -- for testing
}
if pos_functions[poscat] then
local posparams = pos_functions[poscat].params
if type(posparams) == "function" then
posparams = posparams(lang)
end
for key, val in pairs(posparams) do
params[key] = val
end
end
args = require("Module:parameters").process(args, params)
local pagename = args.pagename or mw.loadData("Module:headword/data").pagename
local data = {
lang = lang,
pos_category = poscat,
categories = {},
heads = {},
genders = {},
inflections = { enable_auto_translit = true },
pagename = pagename,
id = args.id,
sort_key = args.sort,
force_cat_output = force_cat,
}
local heads = args.head
for i = 1, #heads do
insert(data.heads, {
term = heads[i],
tr = args.tr[i],
})
end
return require("Module:headword").full_headword(data)
end
pos_functions.nouns = {
params = {
["g"] = {required = true, type = "genders", list = true, allow_holes = false},
["nopl"] = {type = "boolean"},
["pl"] = {list = true, allow_holes = false},
},
func = function(args, data)
local function insert_inflection(terms, label, accel)
m_headword_utilities.insert_inflection {
headdata = data,
terms = terms,
label = label,
accel = accel and {form = accel} or nil,
}
end
if args.nopl or (pl and pl[1] == "-") then
insert(data.categories, langname .. " uncountable nouns")
elseif pl then
insert_inflection(pl, "plural", "p")
end
data.genders = args.g
end,
}
pos_functions.verbs = {
params = {
["pres"] = {list = true, allow_holes = false},
["past"] = {list = true, allow_holes = false},
["part"] = {list = true, allow_holes = false},
},
func = function(args, data)
local function insert_inflection(terms, label, accel)
m_headword_utilities.insert_inflection {
headdata = data,
terms = terms,
label = label,
accel = accel and {form = accel} or nil,
}
end
if pres then
insert_inflection(pres, "first-person singular present", "1|s|pres|ind")
end
if past then
insert_inflection(past, "first-person singular past", "1|s|past|ind")
end
if part then
insert_inflection(part, "past participle", "pastpart")
end
end,
}
return export