45,645
edits
No edit summary Tag: Reverted |
Tag: Undo |
||
Line 1: | Line 1: | ||
local export = {} | 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 params = { | |||
[1] = {required = true, default = "und"}, | |||
["sc"] = plain_param, | |||
["cat sc"] = plain_param, | |||
["sort"] = plain_param, | |||
[2] = {required = true, default = "nouns"}, | [2] = {required = true, default = "nouns"}, | ||
[" | ["noposcat"] = {type = "boolean"}, | ||
["nomultiwordcat"] = {type = "boolean"}, | |||
["nomultiwordcat"] = boolean, | ["nogendercat"] = {type = "boolean"}, | ||
["nogendercat"] = | ["cat2"] = plain_param, | ||
["cat3"] = plain_param, | |||
["cat4"] = plain_param, | |||
["cat2"] = | |||
["cat3"] = | |||
["cat4"] = | |||
["head"] = | ["head"] = {list = true, allow_holes = true, default = ""}, | ||
["id"] = | ["id"] = plain_param, | ||
["tr"] = | ["tr"] = list_with_holes, | ||
["ts"] = | ["ts"] = list_with_holes, | ||
["g"] = {list = true}, | ["g"] = {list = true}, | ||
[" | ["affix"] = {list = true}, | ||
[3] = | [3] = list_with_holes, | ||
["f | ["f=accel-form"] = list_with_holes, | ||
["f | ["f=accel-translit"] = list_with_holes, | ||
["f | ["f=accel-lemma"] = list_with_holes, | ||
["f | ["f=accel-lemma-translit"] = list_with_holes, | ||
["f | ["f=accel-gender"] = list_with_holes, | ||
["f | ["f=accel-nostore"] = {list = true, allow_holes = true, type = "boolean"}, | ||
["f=request"] = list_with_holes, | |||
["f=alt"] = list_with_holes, | |||
["f=sc"] = list_with_holes, | |||
["f | ["f=id"] = list_with_holes, | ||
["f | ["f=tr"] = list_with_holes, | ||
["f | ["f=g"] = list_with_holes, | ||
["f | ["f=qual"] = list_with_holes, | ||
["f | ["f=nolink"] = {list = true, allow_holes = true, type = "boolean"}, | ||
["f | ["f=lang"] = list_with_holes, | ||
["f | } | ||
["f | |||
} | local args = require("Module:parameters").process(frame:getParent().args, params) | ||
local | |||
-- Get language and script information | -- Get language and script information | ||
local data = {} | local data = {} | ||
data.lang = args[1] | data.lang = require("Module:languages").getByCode(args[1]) or require("Module:languages").err(args[1], 1) | ||
data.sort_key = args["sort"] | data.sort_key = args["sort"] | ||
data.heads = args["head"] | data.heads = args["head"] | ||
Line 71: | Line 57: | ||
data.translits = args["tr"] | data.translits = args["tr"] | ||
data.transcriptions = args["ts"] | data.transcriptions = args["ts"] | ||
data.genders = args["g"] | data.genders = args["g"] | ||
data.affix = args["affix"] | |||
-- Script | |||
local cat_sc | |||
if args["cat sc"] then | |||
data.sc = (args["cat sc"] and (require("Module:scripts").getByCode(args["cat sc"]) or error("The script code \"" .. args["cat sc"] .. "\" is not valid.")) or nil) | |||
cat_sc = cat_sc | |||
else | |||
data.sc = (args["sc"] and (require("Module:scripts").getByCode(args["sc"]) or error("The script code \"" .. args["sc"] .. "\" is not valid.")) or nil) | |||
end | end | ||
-- Part-of-speech category | -- Part-of-speech category | ||
data.pos_category = args[2] | |||
data.noposcat = args["noposcat"] | data.noposcat = args["noposcat"] | ||
-- | if not data.pos_category:find("s$") and not invariable[data.pos_category] 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 | |||
-- Additional categories | data.pos_category = data.pos_category .. "s" | ||
end | |||
end | |||
if cat_sc then | |||
data.pos_category = data.pos_category .. " in " .. cat_sc:getCategoryName() | |||
end | |||
-- Additional categories | |||
data.categories = {} | data.categories = {} | ||
data. | data.nomultiwordcat = data.pos_category == "circumfixes" and true or args["nomultiwordcat"] | ||
data.nogendercat = args["nogendercat"] | data.nogendercat = args["nogendercat"] | ||
data. | |||
table.insert(data.categories, "Contionary") | |||
if args["cat2"] then | if args["cat2"] then | ||
insert(data.categories, data.lang: | table.insert(data.categories, data.lang:getCanonicalName() .. " " .. args["cat2"]) | ||
end | end | ||
if args["cat3"] then | if args["cat3"] then | ||
insert(data.categories, data.lang: | table.insert(data.categories, data.lang:getCanonicalName() .. " " .. args["cat3"]) | ||
end | end | ||
if args["cat4"] then | if args["cat4"] then | ||
insert(data.categories, data.lang: | table.insert(data.categories, data.lang:getCanonicalName() .. " " .. args["cat4"]) | ||
end | end | ||
-- Inflected forms | -- Inflected forms | ||
data.inflections = { | data.inflections = {} | ||
for i = 1, math.ceil(args[3].maxindex / 2) do | for i = 1, math.ceil(args[3].maxindex / 2) do | ||
local infl_part = { | local infl_part = { | ||
Line 131: | Line 121: | ||
} or nil, | } or nil, | ||
request = args["frequest"][i], | request = args["frequest"][i], | ||
} | } | ||
local form = { | local form = { | ||
term | term = args[3][i * 2], | ||
alt | alt = args["falt"][i], | ||
genders | genders = {args["fg"][i]}, | ||
id | id = args["fid"][i], | ||
lang | lang = args["flang"][i], | ||
nolink = args["fnolink"][i], | |||
qualifiers = {args["fqual"][i]}, | |||
sc | sc = args["fsc"][i], | ||
translit | translit = args["ftr"][i], | ||
} | } | ||
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 form.term == "?" or form.term == "-" then | |||
table.insert(data.categories, "Contionary stubs") | |||
end | |||
-- If no term or alt is given, then the label is shown alone. | -- If no term or alt is given, then the label is shown alone. | ||
if form.term or form.alt then | if form.term or form.alt then | ||
insert(infl_part, form) | table.insert(infl_part, form) | ||
end | end | ||
Line 155: | Line 155: | ||
-- Append to the previous inflection part, if one exists | -- Append to the previous inflection part, if one exists | ||
if #infl_part > 0 and data.inflections[1] then | if #infl_part > 0 and data.inflections[1] then | ||
insert(data.inflections[#data.inflections], form) | table.insert(data.inflections[#data.inflections], form) | ||
end | end | ||
elseif infl_part.label then | elseif infl_part.label then | ||
-- Add a new inflection part | -- Add a new inflection part | ||
insert(data.inflections, infl_part) | table.insert(data.inflections, infl_part) | ||
end | end | ||
end | end | ||
return | return require("Module:headword").full_headword(data) | ||
end | end | ||
return export | return export |