Module:accel: Difference between revisions

Created page with "local export = {} local form_of_module = "Module:form of" local form_of_data_module = "Module:form of/data" local m_str_utils = require("Module:string utilities") local m_table = require("Module:table") local append = m_table.append local assert = assert local concat = table.concat local contains = m_table.contains local deep_copy = m_table.deepCopy local deep_equals = require("Module:table/deepEquals") local extend = m_table.extend local insert = table.insert local i..."
 
No edit summary
 
Line 115: Line 115:
insert(parts, ("|head%s=%s"):format(paramnum, target.term))
insert(parts, ("|head%s=%s"):format(paramnum, target.term))
end
end
if target.translit then
if target.tr then
insert(parts, ("|tr%s=%s"):format(paramnum, target.translit))
insert(parts, ("|tr%s=%s"):format(paramnum, target.tr))
end
end
end
end
Line 136: Line 136:
end
end
insert(parts, ("|%s%s"):format(termparam, origin.term))
insert(parts, ("|%s%s"):format(termparam, origin.term))
if origin.translit then
if origin.tr then
insert(parts, ("|%s%s"):format(trparam, origin.translit))
insert(parts, ("|%s%s"):format(trparam, origin.tr))
end
end
end
end
Line 190: Line 190:
entry.pos_header = "Participle"
entry.pos_header = "Participle"
entry.head = make_head("past participle")
entry.head = make_head("past participle")
elseif (params.form == "perf|part" or params.form == "perf|ptcp") and params.pos == "verb" then
entry.pos_header = "Participle"
entry.head = make_head("perfect participle")
elseif (params.form == "pres|part" or params.form == "pres|ptcp") and params.pos == "verb" then
elseif (params.form == "pres|part" or params.form == "pres|ptcp") and params.pos == "verb" then
entry.pos_header = "Participle"
entry.pos_header = "Participle"
Line 938: Line 941:




local function split_and_zip_term_and_translit(encoded_term, encoded_translit)
local function split_and_zip_term_and_tr(encoded_term, encoded_tr)
local terms = split(encoded_term, split_term_regex)
local terms = split(encoded_term, split_term_regex)
local translits = encoded_translit and split(encoded_translit, split_term_regex) or {}
local trs = encoded_tr and split(encoded_tr, split_term_regex) or {}
if #translits > #terms then
if #trs > #terms then
error(("Saw %s translits, which is > the %s terms seen: encoded_term=%s, encoded_translit=%s"):
error(("Saw %s translits, which is > the %s terms seen: encoded_term=%s, encoded_tr=%s"):
format(#translits, #terms, encoded_term, encoded_translit))
format(#trs, #terms, encoded_term, encoded_tr))
end
end
local result = {}
local result = {}
for i, term in ipairs(terms) do
for i, term in ipairs(terms) do
local translit = translits[i]
local tr = trs[i]
if translit == "" then
if tr == "" then
translit = nil
tr = nil
end
end
insert(result, {term = term, translit = translit})
insert(result, {term = term, tr = tr})
end
end
return result
return result
Line 957: Line 960:




local function paste_term_translit(termobj)
local function paste_term_tr(termobj)
if termobj.translit then
if termobj.tr then
return termobj.term .. "//" .. termobj.translit
return termobj.term .. "//" .. termobj.tr
else
else
return termobj.term
return termobj.term
Line 1,021: Line 1,024:


params.form = params.form:gsub("|", "|")
params.form = params.form:gsub("|", "|")
params.targets = split_and_zip_term_and_translit(params.target, params.transliteration)
params.targets = split_and_zip_term_and_tr(params.target, params.transliteration)
params.origins = split_and_zip_term_and_translit(params.origin, params.origin_transliteration)
params.origins = split_and_zip_term_and_tr(params.origin, params.origin_transliteration)


for _, origin in ipairs(params.origins) do
for _, origin in ipairs(params.origins) do
add_item(seen_origins, paste_term_translit(origin), origin)
add_item(seen_origins, paste_term_tr(origin), origin)
end
end


for _, target in ipairs(params.targets) do
for _, target in ipairs(params.targets) do
add_item(seen_targets, paste_term_translit(target), target)
add_item(seen_targets, paste_term_tr(target), target)
end
end