Module:pollasena-roots: Difference between revisions

No edit summary
No edit summary
 
(9 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")


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


local export = {}
local export = {}
Line 137: Line 135:
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
local termarg_index = 1
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 175: Line 184:
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 199: Line 208:
terms = {}
terms = {}
local root_index = 1
local root_index = 1
local last_term = ""
for _, item in ipairs(items) do
for _, item in ipairs(items) do
if item.alt and not match(item.alt, "^%*") and ancestor_lang:hasType("reconstructed") then
if item.alt and not match(item.alt, "^%*") and ancestor_lang:hasType("reconstructed") then
Line 207: Line 217:
separator = item.term
separator = item.term
elseif item.term then
elseif item.term then
if root_index > 1 and separator ~= "+" and match(items[root_index - 1].term, "%-$") then -- no asterisk after hyphen
if root_index > 1 and match(last_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 230: Line 240:
root_index = root_index + 1
root_index = root_index + 1
end
end
last_term = item.term
end
end
Line 255: Line 267:
end
end
end
end
 
local etymology = m_etym.format_inherited{
local etymology
lang = dest_lang,
if lang_options.borrowed then
terms = terms,
etymology = m_etym_specialized.specialized_borrowing{
sort_key = args.sort,
bortype = args.p or "b",
nocat = args.nocat,
lang = dest_lang,
conj = lang_options.roots and separator or nil,
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 311:
end
end
local categories = {}
local categories = m_utils.format_categories(cats, dest_lang)
if not parent_args.nocat then
categories = m_utils.format_categories(cats, dest_lang)
end
return etymologies, args, categories
return etymologies, args, parent_args.nocat and "" or categories
end
end


return export
return export