Module:pollasena-roots: Difference between revisions

No edit summary
No edit summary
 
(166 intermediate revisions by the same user not shown)
Line 1: Line 1:
local m_iut = require("Module:inflection utilities")
local m_put = require("Module:parse utilities")
local m_families = require("Module:families")
local m_lang = require("Module:languages")
local m_param = require("Module:parameters")
local m_param_utils = require("Module:parameter utilities")
local m_param_utils = require("Module:parameter utilities")
local m_utils = require("Module:utilities")
local m_etym = require("Module:etymology")
local m_etym_specialized = require("Module:etymology/specialized")
local m_links = require("Module:links")
local m_table = require("Module:table")
local m_table = require("Module:table")


local gsub = mw.ustring.gsub
local gsub = mw.ustring.gsub
local PAGENAME = gsub(mw.title.getCurrentTitle().text, "%s", " ")
local match = mw.ustring.match
local match = mw.ustring.match
local gmatch = mw.ustring.gmatch


local lang = require("Module:languages").getByCode("socl")
local export = {}


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


local function ncategories(categories)
local function get_single_args(args, index)
local out_categories = {}
local single = {}
for key, cat in ipairs(categories) do
for k, v in pairs(args) do
out_categories[key] = "[[Category:" .. cat .. "]]"
if type(v) == "table" and v.maxindex then
if v[index] ~= nil then
single[k] = v[index]
end
else
single[k] = v
end
end
end
 
return single
return table.concat(out_categories, "")
end
end


local function link(term,alt)
function export.parse_args(parent_args, dest_code, ancestor_codes, extra_params)
return "[[Contionary:" .. term .. "|" .. alt or term .. "]]"
local param_mods = m_param_utils.construct_param_mods({{group = {"link", "q", "l"}}})
end
 
local params = extra_params or {}
function export.getLink(frame)
params.nocap = {type = "boolean"} -- no capital letter
local a = 2
params.nocat = {type = "boolean"} -- no categories
local params = {
params.p = {} -- borrowing process
[1] = nil,
[a] = {list = true}, -- Wascotl
local termarg_index
}
if parent_args.borrowing then
termarg_index = 2
params[1] = {
type = "language",
required = true,
}
else
termarg_index = 1
end
local args = require("Module:parameters").process(frame:getParent().args, params)
for _, ancestor in ipairs(ancestor_codes) do
local param_mods = {"alt", "cat"}
local lang_options = ancestor.options or {}
local param_mod_set = m_table.listToSet(param_mods)
local links = {}; local categories = {}
if lang_options.roots then
-- WIP
params[termarg_index] = {
for i, item in ipairs(args[a]) do
required = not lang_options.optional,
if item:find("<") and not item:find("^[^<]*<[a-z]*[^a-z:]") then
list = true,
local run = m_iut.parse_balanced_segment_run(item, "<", ">")
}
local orig_param = i + 1
params["c"] = {
local function parse_err(msg)
list = true,
error(msg .. ": " .. orig_param .. "= " .. table.concat(run))
allow_holes = true,
}
else
params[termarg_index] = {
required = not lang_options.optional,
}
if lang_options.annotated then
params["parts"] = {
sublist = true,
}
end
end
local termobj = {term = {}}
end
termobj.term.lang = lang
termobj.term.term = run[1]
termarg_index = termarg_index + 1
end
m_param_utils.augment_params_with_modifiers(params, param_mods)
local args = m_param.process(parent_args, params)


for j = 2, #run - 1, 2 do
local dest_lang = m_lang.getByCode(dest_code)
if run[j + 1] ~= "" then
local etymologies = {}
parse_err("Extraneous text '" .. run[j + 1] .. "' after modifier")
termarg_index = parent_args.borrowing and 2 or 1
local cats = {}
for _, ancestor in ipairs(ancestor_codes) do
local code = ancestor.code
local lang_options = ancestor.options or {}
local ancestor_lang = m_lang.getByCode(code)
local raw_val = parent_args[termarg_index] or parent_args[tostring(termarg_index)]
if lang_options.optional and (raw_val == nil or raw_val == "") then
termarg_index = termarg_index + 1
else
local terms
local separator = ""
if lang_options.roots then
local items = m_param_utils.parse_list_with_inline_modifiers_and_separate_params({
processed_args = args,
param_mods = param_mods,
termarg = termarg_index,
lang = ancestor_lang,
})
terms = {}
local root_index = 1
local last_term = ""
for _, item in ipairs(items) do
if item.alt and not match(item.alt, "^%*") and ancestor_lang:hasType("reconstructed") then
item.alt = "*" .. item.alt
end
if item.term == "-" or item.term == "+" then
separator = item.term
elseif item.term then
if root_index > 1 and last_term ~= "+" then -- only subsequent asterisks afer space
item.alt = gsub(item.alt or item.term, "^%*", "")
end
table.insert(terms, item)
local function one_asterisk(str)
return "*" .. gsub(str, "^*+", "")
end
local cat_term = one_asterisk(args.c[root_index] or item.term)
if code == "wasc" then -- Wascotl root and suffix handling
local suffix = match(cat_term, "^*[%w']+(%-[%w']+)$")
if wasc_suffixes[suffix] then
cat_term = gsub(cat_term, suffix, "-")
end
end
table.insert(cats, dest_lang:getCanonicalName() .. " terms derived from the " .. ancestor_lang:getCanonicalName() .. " root " .. cat_term)
root_index = root_index + 1
end
last_term = item.term
end
end
local modtext = run[j]:match("^<(.*)>$")
if not modtext then
if not terms[1] then
parse_err("Internal error: Modifier '" .. modtext .. "' isn't surrounded by angle brackets")
terms[1] = { lang = ancestor_lang }
end
end
local prefix, arg = modtext:match("^([a-z]+):(.*)$")
if not prefix then
parse_err("Modifier " .. run[j] .. " lacks a prefix, should begin with one of '" ..
else
table.concat(param_mods, ":', '") .. ":'")
local single_args = get_single_args(args, termarg_index)
local parsed = m_param_utils.parse_term_with_inline_modifiers_and_separate_params({
processed_args = single_args,
param_mods = param_mods,
termarg = termarg_index,
lang = ancestor_lang,
})
 
terms = parsed.terms or {}
if not terms[1] then
if parsed.term then
terms[1] = parsed
else
terms[1] = { lang = ancestor_lang }
end
end
end
if param_mod_set[prefix] then
end
local obj = termobj.term
if obj[prefix] then
local etymology
parse_err("Modifier '" .. prefix .. "' occurs twice, second occurrence " .. run[j])
if lang_options.borrowed then
end
etymology = m_etym_specialized.specialized_borrowing{
bortype = args.p or "b",
lang = dest_lang,
sources = {ancestor_lang},
terms = terms,
sort_key = args.sort,
nocat = args.nocat,
conj = lang_options.roots and separator or nil,
nocap = args.mid or args.old or args.nocap,
}
else
etymology = m_etym.format_inherited{
lang = dest_lang,
terms = terms,
sort_key = args.sort,
nocat = args.nocat,
conj = lang_options.roots and separator or nil,
}
etymology = "from " .. etymology
end
if lang_options.annotated and args.parts then
local referrals = {}
for _, part in ipairs(args.parts) do
local referral = m_links.full_link({
lang = ancestor_lang,
term = part,
}, "term")
table.insert(links, link(obj.term, obj["alt"]))
table.insert(referrals, referral)
table.insert(categories, "Soc'ul' terms derived from Wascotl *" .. obj["cat"] or obj.term)
else
parse_err("Unrecognized prefix '" .. prefix .. "' in modifier " .. run[j])
end
end
etymology = etymology .. " (see " .. m_table.serialCommaJoin(referrals) .. ")"
end
end
args[a][i] = termobj
table.insert(etymologies, etymology)
termarg_index = termarg_index + 1
end
end
end
end
return table.concat(links) .. ncategories(categories)
local categories = m_utils.format_categories(cats, dest_lang)
return etymologies, args, parent_args.nocat and "" or categories
end
end


return export
return export