local export = {}
-- Part of speech types that should not be pluralized.
local invariable = mw.loadData("Module:headword/data").invariable
function export.head_t(frame)
local plain_param = {}
local list_with_holes = {list = true, allow_holes = true}
local boolean_list_with_holes = {list = true, allow_holes = true, type = "boolean"}
local params = {
= {required = true, default = "und"},
= plain_param,
= plain_param,
= {required = true, default = "nouns"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= plain_param,
= plain_param,
= plain_param,
= {list = true, allow_holes = true, default = ""},
= plain_param,
= list_with_holes,
= list_with_holes,
= {list = true},
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= boolean_list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= boolean_list_with_holes,
= boolean_list_with_holes,
= list_with_holes,
}
local args = require("Module:parameters").process(frame:getParent().args, params)
-- Get language and script information
local data = {}
data.lang = require("Module:languages").getByCode(args) or require("Module:languages").err(args, 1)
data.sort_key = args
data.heads = args
data.id = args
data.translits = args
data.transcriptions = args
data.genders = args
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
-- Script
data.sc = args and require("Module:scripts").getByCode(args, "sc") or nil
data.sccat = args
-- Part-of-speech category
data.pos_category = args
data.noposcat = args
if not data.pos_category:find("s$") and not invariable then
-- Make the plural form of the part of speech
if data.pos_category:find("x$") then -- prefix, suffix, confix, infix, circumfix, affix, interfix, transfix
data.pos_category = data.pos_category .. "es"
else
data.pos_category = data.pos_category .. "s"
end
end
-- Additional categories
data.categories = {}
data.nomultiwordcat = args
data.nogendercat = args
data.nopalindromecat = args
if args then
table.insert(data.categories, data.lang:getCanonicalName() .. " " .. args)
end
if args then
table.insert(data.categories, data.lang:getCanonicalName() .. " " .. args)
end
if args then
table.insert(data.categories, data.lang:getCanonicalName() .. " " .. args)
end
-- 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,
nolink = args,
qualifiers = {args},
sc = args,
translit = args,
transcription = args,
}
if form.lang then
form.lang = require("Module:languages").getByCode(form.lang) or require("Module:languages").err(form.lang, "f" .. i .. "lang")
end
if form.sc then
form.sc = require("Module:scripts").getByCode(form.sc) or error("The script code \"" .. form.sc .. "\" is not valid.")
end
-- 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