This is a private module sandbox of Benwing2, for their own experimentation. Items in this module may be added and removed at Benwing2's discretion; do not rely on this module's stability.
local process_params = require("Module:parameters").process
local export = {}
local function get_args(frame)
local boolean = {type = "boolean"}
local boolean_list_allow_holes = {type = "boolean", list = true, allow_holes = true}
local list_allow_holes = {list = true, allow_holes = true}
local plain = {}
return process_params(frame:getParent().args, {
= {required = true, type = "language", etym_lang = true, default = "und"},
= {type = "script"},
= plain,
= {required = true, default = "nouns"},
= boolean,
= boolean,
= boolean,
= boolean,
= boolean,
= boolean,
= boolean,
= plain,
= plain,
= plain,
= list_allow_holes,
= plain,
= list_allow_holes,
= list_allow_holes,
= plain,
= {list = true},
= list_allow_holes,
= list_allow_holes,
= list_allow_holes,
= list_allow_holes,
= list_allow_holes,
= list_allow_holes,
= list_allow_holes,
= boolean_list_allow_holes,
= list_allow_holes,
= list_allow_holes,
= {list = true, allow_holes = true, type = "language", etym_lang = true},
= {list = true, allow_holes = true, type = "script"},
= list_allow_holes,
= list_allow_holes,
= list_allow_holes,
= list_allow_holes,
= list_allow_holes,
= boolean_list_allow_holes,
= boolean_list_allow_holes,
})
end
function export.head_t(frame)
local function track(page)
require("Module:debug/track")("headword/templates/" .. page)
return true
end
local args = get_args(frame)
-- Get language and script information
local data = {}
data.lang = args
data.sc = args
data.sccat = args
data.sort_key = args
data.heads = args
data.id = args
data.translits = args
data.transcriptions = args
data.gloss = args
data.genders = args
-- This shouldn't really happen.
for i = 1,args.maxindex do
if not args then
track("head-with-holes")
end
end
for k, v in pairs(args) do
if k ~= "maxindex" then
if data.genders then
data.genders = {spec = data.genders, qualifiers = {v}}
else
k = k == 1 and "" or tostring(k)
error(("g%squal= specified without g%s="):format(k, k))
end
end
end
-- Part-of-speech category
data.pos_category = args
data.noposcat = args
local headword_data = mw.loadData("Module:headword/data")
-- Check for headword aliases and then pluralize if the POS term does not have an invariable plural.
data.pos_category = headword_data.pos_aliases or data.pos_category
if not data.pos_category:find("s$") and not headword_data.invariable then
-- Make the plural form of the part of speech
data.pos_category = data.pos_category:gsub("x$", "%0e") .. "s"
end
-- Additional categories.
data.categories = {}
data.whole_page_categories = {}
data.nomultiwordcat = args
data.nogendercat = args
data.nopalindromecat = args
if args then
table.insert(data.categories, data.lang:getFullName() .. " " .. args)
end
if args then
table.insert(data.categories, data.lang:getFullName() .. " " .. args)
end
if args then
table.insert(data.categories, data.lang:getFullName() .. " " .. args)
end
-- Headword linking
data.nolinkhead = args
-- Inflected forms
data.inflections = {enable_auto_translit = args}
for i = 1, math.ceil(args.maxindex / 2) do
local infl_part = {
label = args,
accel = args and {
form = args,
translit = args,
lemma = args,
lemma_translit = args,
gender = args,
nostore = args,
} or nil,
request = args,
enable_auto_translit = args,
}
local form = {
term = args,
alt = args,
genders = args and mw.text.split(args, ",") or {},
id = args,
lang = args,
nolinkinfl = args,
q = {args},
sc = args,
translit = args,
transcription = args,
}
-- If no term or alt is given, then the label is shown alone.
if form.term or form.alt then
table.insert(infl_part, form)
end
if infl_part.label == "or" then
-- Append to the previous inflection part, if one exists
if #infl_part > 0 and data.inflections then
table.insert(data.inflections, form)
end
elseif infl_part.label then
-- Add a new inflection part
table.insert(data.inflections, infl_part)
end
end
return require("Module:headword").full_headword(data)
end
return export