Module:pollasena-roots: Difference between revisions
No edit summary |
No edit summary |
||
| (16 intermediate revisions by the same user not shown) | |||
| Line 7: | Line 7: | ||
local m_utils = require("Module:utilities") | local m_utils = require("Module:utilities") | ||
local m_etym = require("Module:etymology") | local m_etym = require("Module:etymology") | ||
local m_etym_specialized = require("Module:etymology/specialized") | |||
local m_links = require("Module:links") | local m_links = require("Module:links") | ||
local m_table = require("Module:table") | local m_table = require("Module:table") | ||
| Line 16: | Line 17: | ||
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", "-tl", | |||
} | } | ||
local function get_single_args(args, index) | local function get_single_args(args, index) | ||
| Line 134: | Line 39: | ||
local params = extra_params or {} | local params = extra_params or {} | ||
params.nocap = {type = "boolean"} | params.nocap = {type = "boolean"} -- no capital letter | ||
params.nocat = {type = "boolean"} | params.nocat = {type = "boolean"} -- no categories | ||
params.p = {} -- borrowing process | |||
local termarg_index | |||
if parent_args.borrowing then | |||
termarg_index = 2 | |||
params[1] = { | |||
type = "language", | |||
required = true, | |||
} | |||
else | |||
termarg_index = 1 | |||
end | |||
for _, ancestor in ipairs(ancestor_codes) do | for _, ancestor in ipairs(ancestor_codes) do | ||
local lang_options = ancestor.options or {} | local lang_options = ancestor.options or {} | ||
| Line 172: | Line 88: | ||
local etymologies = {} | local etymologies = {} | ||
termarg_index = 1 | termarg_index = parent_args.borrowing and 2 or 1 | ||
local cats = {} | local cats = {} | ||
for _, ancestor in ipairs(ancestor_codes) do | for _, ancestor in ipairs(ancestor_codes) do | ||
| Line 205: | Line 121: | ||
separator = item.term | separator = item.term | ||
elseif item.term then | elseif item.term then | ||
if root_index > 1 and | if root_index > 1 and last_term ~= "+" then -- only subsequent asterisks afer space | ||
item.alt = gsub(item.alt or item.term, "^%*", "") | |||
end | end | ||
table.insert(terms, item) | table.insert(terms, item) | ||
local | 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 | 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 | ||
table.insert(cats, dest_lang:getCanonicalName() .. " terms from " .. ancestor_lang:getCanonicalName() .. " " .. cat_term) | table.insert(cats, dest_lang:getCanonicalName() .. " terms derived from the " .. ancestor_lang:getCanonicalName() .. " root " .. cat_term) | ||
root_index = root_index + 1 | root_index = root_index + 1 | ||
| Line 255: | Line 170: | ||
end | end | ||
end | end | ||
local etymology = m_etym.format_inherited{ | local etymology | ||
if lang_options.borrowed then | |||
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 | if lang_options.annotated and args.parts then | ||
| Line 284: | Line 214: | ||
end | end | ||
local | local categories = m_utils.format_categories(cats, dest_lang) | ||
return etymologies, args, categories | return etymologies, args, parent_args.nocat and "" or categories | ||
end | end | ||
return export | return export | ||