Modifiche

Modulo:Headword/templates

1 800 byte rimossi, 05:12, 5 set 2018
m
174 versioni importate
local export = {}
local lemmas = { ["acronym"] = true, ["adjective"] = true, ["adverb"] = true, ["article"] = true, ["circumfix"] = true, ["circumposition"] = true, ["conjunction"] = true, ["determiner"] = true, ["gismu"] = true, ["Han tu"] = true, ["hanzi"] = true, ["hanja"] = true, ["idiom"] = true, ["interjection"] = true, ["kanji"] = true, ["letter"] = true, ["noun"] = true, ["numeral"] = true, ["phrase"] = true, ["postposition"] = true, ["prefix"] = true, ["preposition"] = true, ["prepositional phrase"] = true, ["pronoun"] = true, ["proverb"] = true, ["proper noun"] = true, ["root"] = true, ["suffix"] = true, ["symbol"] = true, ["verb"] = true,}-- Part of speech types that should not be pluralized.local nonlemmas = { ["adjective form"] invariable = true, ["adjective comparative formmw.loadData("] = true, [Module:headword/data"adjective superlative form"] = true, ["adverb form"] = true, ["adverb comparative form"] = true, ["adverb superlative form"] = true, ["determiner form"] = true, ["jyutping"] = true, ["kanji reading"] = true, ["noun form"] = true, ["numeral form"] = true, ["participle"] = true, ["participle form"] = true, ["past participle"] = true, ["past participle form"] = true, ["pinyin"] = true, ["plural"] = true, ["present participle"] = true, ["pronoun form"] = true, ["rafsi"] = true, ["romanization"] = true, ["romaji"] = true, ["verb form"] = true,} local ).invariable = { ["gismu"] = true, ["Han tu"] = true, ["hanzi"] = true, ["hanja"] = true, ["jyutping"] = true, ["kanji"] = true, ["phrasebook"] = true, ["pinyin"] = true, ["punctuation"] = true, ["rafsi"] = true, ["romaji"] = true,}
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"}, ["cat2"] = plain_param, ["cat3"] = plain_param, ["cat4"] = plain_param, ["head"] = {list = true, allow_holes = true, default = ""}, ["id"] = plain_param, ["tr"] = list_with_holes, -- See also "ts" at bottom. ["g"] = {list = true}, [3] = list_with_holes, ["f=accel"] = list_with_holes, ["f=request"] = list_with_holes, ["f=alt"] = list_with_holes, ["f=sc"] = list_with_holes, ["f=id"] = list_with_holes, ["f=tr"] = list_with_holes, ["f=g"] = list_with_holes, ["f=qual"] = list_with_holes, ["f=nolink"] = {list = true, allow_holes = true, type = "boolean"}, ["f=lang"] = list_with_holes, -- Belongs after "tr", but has to be placed here, or args["falt"] will vanish. ["ts"] = 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[1] ) or require(mw.title.getCurrentTitle().nsText == "Template" and "undModule:languages") or error.err("Language code has not been specified. Please pass parameter args[1], 1 to the template.") local sc data.sort_key = args["scsort"] or ""; if sc = data.heads = args["head" then sc = nil end] lang data.id = require(args["Module:languagesid")] data.getByCode(lang) or error("The language code \translits = args["tr" ] data.. lang .. transcriptions = args["\ts" is not valid.")] sc data.genders = (sc and (require(args["Module:scriptsg").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)] -- Script local cat_sc
-- Gather basic parametersif args["cat sc"] then local sort_key data.sc = (args["sortcat sc"]; if sort_key == and (require("Module:scripts" then sort_key = nil end local pos = ).getByCode(args[2"cat sc"]; if pos == ) or error("The script code \"" then pos = nil end local cat = .. args["catsc"]; if cat == .. "\"is not valid." then cat )) or nil) cat_sc = nil endcat_sc local cat2 else data.sc = (args["cat2sc"]; if cat2 == and (require("Module:scripts" then cat2 = nil end local cat3 = ).getByCode(args["cat3sc"]; if cat3 == ) or error("The script code \"" then cat3 = nil end local tr = .. args["trsc"]; if tr == .. "\"is not valid." then tr = )) or nil ) end
-- Gather headwordsPart-of-speech category local head data.pos_category = args["head"] local heads = {head or ""} local i = 2 head = args["head" .. i]
while head doif not data.pos_category:find("s$") and not invariable[data.pos_category] then -- Make the plural form of the part of speech if head ~data.pos_category:find("x$") then -- prefix, suffix, confix, infix, circumfix, affix, interfix, transfix data.pos_category = data.pos_category .. "es" then else tabledata.pos_category = data.pos_category ..insert(heads, head)"s"
end
i = i + 1
head = args["head" .. i]
end
-- Gather gender and number specificationsif cat_sc then -- Iterate over all gn parameters data.pos_category = data.pos_category .. " in " .. cat_sc:getCategoryName(g2, g3 and so on) until one is empty local genders = {}end local g = args["g"]; if g == "" then g = nil end-- Additional categories local i data.categories = 2{}
while g doif args["cat2"] then table.insert(gendersdata.categories, gdata.lang:getCanonicalName() g = args[.. "g" .. i]; if g == args["cat2" then g = nil end i = i + 1])
end
-- Gather inflected formsif args["cat3"] then table.insert(data.categories, data.lang:getCanonicalName() .. " " .. args["cat3"]) local inflections = {}end
local i = 1 local label = if args[i * 2 + 1"cat4"]then local accel = args["f" table.insert(data.categories, data. i lang:getCanonicalName() .. "accel"]; if accel == "" then accel = nil end local nolink = .. args["f" .. i .. "nolinkcat4"]; if nolink == "" then nolink = nil end) local parts = {label = label, accel = accel, nolink = nolink}end
local m_scripts -- Inflected forms data.inflections = nil{}
while label for i = 1, math.ceil(args[3].maxindex / 2) do local term infl_part = { label = args[3][i * 2 + 2- 1]; if term == "" then term = nil end, local alt accel = args["f" .. i .. "altfaccel"]; if alt == "" then alt = nil end local sc = args["f" .. i .. "sc"]; if sc == "" then sc = nil end, local id request = args["f" .. i .. "idfrequest"]; if id == "" then id = nil end local gender = args["f" .. i .. "g"]; if gender == "" then gender = nil end, }
if local form = { term or = args[3][i * 2], alt then = args["falt"][i], genders = {args["fg"][i]}, id = args["fid"][i], lang = args["flang"][i], nolink = args["fnolink"][i], qualifiers = {args["fqual"][i]}, sc = args["fsc"][i], translit = args["ftr"][i], } if sc form.lang then m_scripts form.lang = m_scripts or require("Module:scriptslanguages") sc = (sc and (m_scripts.getByCode(scform.lang) or errorrequire("The script code \Module:languages").err(form.lang, "f" .. sc i .. "\" is not valid.lang")) or nil) end table.insert(parts, {term = term, alt = alt, sc = sc, id = id, genders = {gender}})
end
i = i + 1if form.sc then label form.sc = args[i * 2 + 1] accel = args[require("fModule:scripts" ).getByCode(form. i .. "accel"]; if accel == sc) or error("The script code \" then accel = nil end nolink = args["f" .. i form.sc . "nolink"]; if nolink == "" then nolink = nil end -- If the next label is not "or" then insert the previous one and create a new one. if label ~= "or\" then -- Only insert if the previous label is not emptyvalid. if (parts.label or "") ~= "" then table.insert(inflections, parts) end parts = {label = label, accel = accel, nolink = nolink}
end
end
-- Get/set categories
local categories = {}
if cat then
table.insert(categories, lang:getCanonicalName() .. " " .. cat)
if pos -- If no term or alt is given, then tablethe label is shown alone.insert(categories, "head tracking/with cat/with pos") else table.insert(categories, "head tracking/with cat/no pos") require("Module:debug").track("head tracking/no pos/lang/" .. lang:getCode()) end elseif pos then if lemmas[pos] then tableform.insert(categories, lang:getCanonicalName() term or form.. " lemmas") elseif not nonlemmas[pos] alt then table.insert(categoriesinfl_part, "head tracking/unrecognized pos") require("Module:debug").track("head tracking/unrecognized pos/pos/" .. pos) require("Module:debug").track("head tracking/unrecognized pos/lang/" .. lang:getCode()form)
end
if infl_part.label == "or" then -- Make the plural form of Append to the previous inflection part of speech, if one exists if pos:find#infl_part > 0 and data.inflections[1] then table.insert("x$"data.inflections[#data.inflections], form) then pos = pos .. "es"end elseif not invariable[pos] infl_part.label then pos = pos -- Add a new inflection part table.insert(data. "s"inflections, infl_part)
end
table.insert(categories, lang:getCanonicalName() .. " " .. pos)
else
table.insert(categories, "head tracking/no pos")
require("Module:debug").track("head tracking/no pos/lang/" .. lang:getCode())
end
if cat2 then
table.insert(categories, lang:getCanonicalName() .. " " .. cat2)
end
if cat3 then
table.insert(categories, lang:getCanonicalName() .. " " .. cat3)
end
return require("Module:headword").full_headword(lang, sc, heads, tr, genders, inflections, categories, sort_key) .. require("Module:utilities").format_categories(categories, lang, sort_keydata)
end
return export

Menu di navigazione