Module:taln-headword: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 26: | Line 26: | ||
["pagename"] = {}, -- for testing | ["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 | |||
local args = require("Module:parameters").process(parargs, params) | |||
local pagename = args.pagename or mw.loadData("Module:headword/data").pagename | local pagename = args.pagename or mw.loadData("Module:headword/data").pagename | ||
| Line 59: | Line 69: | ||
end | end | ||
pos_functions.nouns = | pos_functions.nouns = { | ||
params = { | |||
["g"] = {required = true, type = "genders"}, | ["g"] = {required = true, type = "genders"}, | ||
["nopl"] = {type = "boolean"}, | ["nopl"] = {type = "boolean"}, | ||
["pl"] = {list = true, allow_holes = false}, | ["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 | |||
end, | |||
end | } | ||
pos_functions.verbs = | pos_functions.verbs = { | ||
params = { | |||
["pres"] = {list = true, allow_holes = false}, | ["pres"] = {list = true, allow_holes = false}, | ||
["past"] = {list = true, allow_holes = false}, | ["past"] = {list = true, allow_holes = false}, | ||
["part"] = {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, | |||
end | } | ||
return export | return export | ||
Revision as of 12:32, 21 June 2026
- This module lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
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 poscat = frame.args[1] or
error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local parargs = frame:getParent().args
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
local args = require("Module:parameters").process(parargs, 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
if pos_functions[poscat] then
pos_functions[poscat](args, data)
end
return require("Module:headword").full_headword(data)
end
pos_functions.nouns = {
params = {
["g"] = {required = true, type = "genders"},
["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
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