Headword-line module, used to deploy the Hiligaynon headword-line templates.
local export = {}
local pos_functions = {}
local force_cat = false -- for testing
local lang = require("Module:languages").getByCode("hil")
local langname = lang:getCanonicalName()
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local poscat = frame.args or require("Module:string utilities").pluralize(args) or error("Part of speech has not been specified. Please pass parameter 1= or pos= to the module invocation.")
local params = {
= {list = true, allow_holes = true},
= {alias_of = "head"},
= {},
= {type = "boolean"},
= {type = "boolean"},
= {type = "boolean"},
= {}, -- for testing
}
if pos_functions then
for key, val in pairs(pos_functions.params) do
params = val
end
end
local args = require("Module:parameters").process(frame:getParent().args, params)
local pagename = args.pagename or mw.title.getCurrentTitle().subpageText
local user_specified_heads = args.head
local data = {
lang = lang,
pos_category = poscat,
categories = {},
heads = args.head,
user_specified_heads = user_specified_heads,
inflections = {},
pagename = pagename,
id = args.id,
force_cat_output = force_cat,
}
local is_suffix = false
if args.suff then
is_suffix = true
data.pos_category = "suffixes"
local singular_poscat = require("Module:string utilities").singularize(poscat)
table.insert(data.categories, langname .. " " .. singular_poscat .. "-forming suffixes")
table.insert(data.inflections, {label = singular_poscat .. "-forming suffix"})
end
if pos_functions then
pos_functions.func(args, data, is_suffix)
end
local content = mw.title.new(pagename):getContent()
local code = content and mw.ustring.match(content, "{{hil%-IPA*}}")
--Categorize words without ]
if not code then
table.insert(data.categories, langname .. " terms without hil-IPA template")
end
if args.json then
return require("Module:JSON").toJSON(data)
end
return require("Module:headword").full_headword(data)
end
local function handle_infl(args, data, argpref, label, accelform)
local forms = args
if #forms > 0 then
forms.label = label
if accelform then
forms.accel = {form = accelform}
end
table.insert(data.inflections, forms)
end
end
pos_functions = {
params = {
= {list = true},
= {alias_of = "real"}, --realis aspect
= {list = true},
= {alias_of = "imp"}, --imperative
= {list = true},
= {list = true},
= {list = true},
},
func = function(args, data)
handle_infl(args, data, "real", "realis", "realis")
handle_infl(args, data, "imp", "imperative", "imp")
handle_infl(args, data, "dim", "diminutive")
handle_infl(args, data, "caus", "causative")
handle_infl(args, data, "freq", "frequentative")
end
}
pos_functions = {
params = {
= {list = true},
= {alias_of = "sup"}, --superlative
= {list = true},
= {list = true},
},
func = function(args, data)
handle_infl(args, data, "sup", "superlative", "superlative")
handle_infl(args, data, "caus", "causative")
handle_infl(args, data, "dim", "diminutive")
end
}
pos_functions = {
params = {
= {list = true},
= {alias_of = "pl"}, --special plural cases only
= {list = true},
= {list = true},
= {list = true},
},
func = function(args, data)
handle_infl(args, data, "pl", "plural", "p")
handle_infl(args, data, "dim", "diminutive")
handle_infl(args, data, "f", "feminine")
handle_infl(args, data, "m", "masculine")
end
}
return export