Module:pollasena-roots: Difference between revisions

No edit summary
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 19: Line 19:


local wasc_suffixes = m_table.listToSet {
local wasc_suffixes = m_table.listToSet {
"ati", "cosc", "e", "ekan", "i", "ila",
"-ati", "-cosc", "-e", "-ekan", "-i", "-ila",
"kan", "la", "osc", "otl", "que", "scati", "si"
"-kan", "-la", "-osc", "-otl", "-que", "-scati", "-si"
}
}


Line 133: Line 133:
end
end


local function parse_args(parent_args, dest_code, ancestor_codes, extra_params)
function export.parse_args(parent_args, dest_code, ancestor_codes, extra_params)
local param_mods = m_param_utils.construct_param_mods({{group = {"link", "q", "l"}}})
local param_mods = m_param_utils.construct_param_mods({{group = {"link", "q", "l"}}})
Line 207: Line 207:
separator = item.term
separator = item.term
elseif item.term then
elseif item.term then
if root_index > 1 and match(items[root_index - 1].term, "%-$") then -- no asterisk after hyphen
if root_index > 1 and separator ~= "+" and match(items[root_index - 1].term, "%-$") then -- no asterisk after hyphen
if not item.alt then
if not item.alt then
item.alt = item.term:gsub("^%*", "")
item.alt = item.term:gsub("^%*", "")
Line 218: Line 218:
local cat_term = args.c[root_index] or item.term
local cat_term = args.c[root_index] or item.term
cat_term = "*" .. gsub(cat_term, "^*+", "") -- ensure only one asterisk
cat_term = "*" .. gsub(cat_term, "^*+", "") -- ensure only one asterisk
if code == "wasc" and cat_term ~= item.term then -- Wascotl root and suffix handling
if code == "wasc" then -- Wascotl root and suffix handling
local suffix = match(cat_term, "^*%w+%-(%w+)$")
local suffix = match(cat_term, "^*[%w']+(%-[%w']+)$")
if wasc_suffixes[suffix] then
if wasc_suffixes[suffix] then
cat_term = gsub(cat_term, suffix, "")
cat_term = gsub(cat_term, suffix, "-")
end
end
end
end
Line 264: Line 264:
}
}
if lang_options.annotated then
if lang_options.annotated and args.parts then
local referrals = {}
local referrals = {}
for _, part in args.parts do
for _, part in ipairs(args.parts) do
local referral = m_links.full_link {
local referral = m_links.full_link({
lang = dest_lang,
lang = ancestor_lang,
term = part,
term = part,
}
}, "term")
table.insert(referrals, referral)
table.insert(referrals, referral)
Line 290: Line 290:
return etymologies, args, categories
return etymologies, args, categories
end
local function concat_etymologies(args, etymologies)
local capital = args.nocap and "f" or "F"
return capital .. "rom " .. table.concat(etymologies, ", from ") .. "."
end
function export.qsc(frame)
local parent_args = frame:getParent().args
local ancestor_codes = {
{ code = "sekh" },
{ code = "wasc", options = {optional = true, roots = true } }
}
local evolution, args, categories = parse_args(parent_args, "qsc", ancestor_codes)
return concat_etymologies(args, evolution) .. categories
end
function export.lyti_inh(frame)
local parent_args = frame:getParent().args
local ancestor_codes = {
{ code = "lyti-mid", options = {} },
{ code = "lyti-old", options = {} },
{ code = "cel-pro", options = {annotated = true} },
{ code = "ine-pro", options = {roots = true} },
}
local extra_params = {
mid = {type = "boolean"},
old = {type = "boolean"},
source = {},
}
local evolution, args, categories = parse_args(parent_args, "lyti", ancestor_codes)
return concat_etymologies(args, evolution) .. categories
end
function export.lyti_loan(frame)
local parent_args = frame:getParent().args
local source_code = parent_args.source or "und"
local ancestor_codes = {
{ code = "lyti-mid", options = {optional = not parent_args.mid} },
{ code = "lyti-old", options = {optional = not parent_args.old} },
{ code = source_code, options = {} },
}
local extra_params = {
mid = {type = "boolean"},
old = {type = "boolean"},
source = {},
}
local evolution, args, categories = parse_args(parent_args, "lyti", ancestor_codes)
return concat_etymologies(args, evolution) .. categories
end
end


return export
return export