local export = {}
local pos_functions = {}
local lang = require("Module:languages").getByCode("kmr")
local langname = lang:getCanonicalName()
local PAGENAME = mw.title.getCurrentTitle().text
local suffix_categories = {
= true,
= true,
= true,
= true,
}
local function track(page)
require("Module:debug").track("kmr-headword/" .. page)
return true
end
local function glossary_link(entry, text)
text = text or entry
return "]"
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local tracking_categories = {}
local poscat = frame.args
or error("Plural part of speech e.g. 'nouns' has not been specified. Please pass parameter 1 to the module invocation.")
local params = {
= {list = true},
= {list = true, allow_holes = true},
= {},
= {type = "boolean"},
}
if pos_functions then
for key, val in pairs(pos_functions.params) do
params = val
end
end
local parargs = frame:getParent().args
local args = require("Module:parameters").process(parargs, params)
local data = {
lang = lang,
pos_category = poscat,
categories = {},
heads = args,
translits = args,
genders = {},
inflections = {},
id = args,
categories = {}
}
if args then
data.pos_category = "suffixes"
if suffix_categories then
local singular_poscat = poscat:gsub("s$", "")
table.insert(data.categories, langname .. " " .. singular_poscat .. "-forming suffixes")
else
error("No category exists for suffixes forming " .. poscat .. ".")
end
end
if pos_functions then
pos_functions.func(args, data, tracking_categories)
end
return require("Module:User:Benwing2/headword").full_headword(data)
.. require("Module:utilities").format_categories(tracking_categories, lang)
end
pos_functions = {
params = {
= {},
= {},
},
func = function(args, data, tracking_categories)
if args then
table.insert(data.inflections, {label = "third-person singular simple present", args})
end
if args then
table.insert(data.inflections, {label = "past tense", args})
end
end
}
pos_functions = {
params = {
= {alias_of = "comparative"},
= {list = true}, --comparative(s)
= {alias_of = "superlative"},
= {list = true}, --superlative(s)
},
func = function(args, data, tracking_categories)
if args.comparative == "-" then
table.insert(data.inflections, {label = "not comparable"})
table.insert(data.categories, langname .. " uncomparable adjectives")
else
if #args.comparative > 0 then
args.comparative.label = glossary_link("comparative")
args.comparative.accel = {form = "comparative"}
table.insert(data.inflections, args.comparative)
end
if #args.superlative > 0 then
args.superlative.label = glossary_link("superlative")
args.superlative.accel = {form = "superlative"}
table.insert(data.inflections, args.superlative)
end
end
end
}
local noun_params = {
= {alias_of = "g"},
= {list = true}, --gender(s)
= {alias_of = "pl"},
= {list = true}, --plural(s)
= {list = true}, --feminine form(s)
= {list = true}, --masculine form(s)
}
local allowed_genders = {
= true,
= true,
= true,
= true,
= true,
= true,
= true,
}
local function do_nouns(pos, args, data, tracking_categories)
local genders = {}
for _, g in ipairs(args.g) do
if not allowed_genders then
error("Unrecognized gender: " .. g)
end
if g == "mf" then
table.insert(genders, "m")
table.insert(genders, "f")
else
table.insert(genders, g)
end
end
if #genders > 0 then
data.genders = genders
else
data.genders = {"?"}
end
local plpos = require("Module:string utilities").pluralize(pos)
-- Check for special plural signals
local mode = nil
if args.pl == "?" or args.pl == "!" or args.pl == "-" or args.pl == "-~" or args.pl == "~" or args.pl == "#" then
mode = args.pl
table.remove(args.pl, 1) -- Remove the mode parameter
end
if mode == "?" then
-- Plural is unknown
table.insert(data.categories, langname .. " " .. plpos .. " with unknown or uncertain plurals")
elseif mode == "!" then
-- Plural is not attested
table.insert(data.inflections, {label = "plural not attested"})
table.insert(data.categories, langname .. " " .. plpos .. " with unattested plurals")
return
elseif mode == "-" then
-- Uncountable noun; may occasionally have a plural
table.insert(data.categories, langname .. " uncountable " .. plpos)
table.insert(data.inflections, {label = glossary_link("uncountable")})
elseif mode == "-~" then
table.insert(data.categories, langname .. " uncountable " .. plpos)
table.insert(data.inflections, {label = "usually " .. glossary_link("uncountable")})
elseif mode == "~" then
-- Mixed countable/uncountable noun, always has a plural
table.insert(data.inflections, {label = glossary_link("countable") .. " and " .. glossary_link("uncountable")})
table.insert(data.categories, langname .. " uncountable " .. plpos)
table.insert(data.categories, langname .. " countable " .. plpos)
elseif mode == "#" or pos == "noun" then
-- Countable nouns; the default for regular nouns but not proper nouns
if mode == "#" then
table.insert(data.inflections, {label = glossary_link("countable")})
end
-- Not enough nouns properly use - in the second argument
-- table.insert(data.categories, langname .. " countable " .. plpos)
end
if #args.pl > 0 then
args.pl.label = "plural"
args.pl.accel = {form = "p"}
table.insert(data.inflections, args.pl)
end
if #args.f > 0 then
args.f.label = "feminine"
table.insert(data.inflections, args.f)
end
if #args.m > 0 then
args.m.label = "masculine"
table.insert(data.inflections, args.m)
end
end
pos_functions = {
params = noun_params,
func = function(args, data, tracking_categories)
return do_nouns("noun", args, data, tracking_categories)
end,
}
pos_functions = {
params = noun_params,
func = function(args, data, tracking_categories)
return do_nouns("proper noun", args, data, tracking_categories)
end,
}
return export