Module:曲师列表:修订间差异

Admin​(留言 | 贡献)
接入 模块:数据页校验:数据页结构错误时显红字并归入 分类:数据页异常(不再静默渲染空表)
Admin​(留言 | 贡献)
改用 模块:署名解析 统一拆词;标题下显示实时曲目数(替代映射表中无法维护的 _曲目数)
第12行: 第12行:
local DIFFS = { 'CASUAL', 'TOUGH', 'INSANE', 'PRO' }
local DIFFS = { 'CASUAL', 'TOUGH', 'INSANE', 'PRO' }


-- 含分隔符但其实是"单人名义"的写法, 不拆分 (键为 norm() 后的值)
-- 拆词与归一化统一由 模块:署名解析 提供(本模块不再自带一份,避免规则漂移)
local NO_SPLIT = {
local parse = require('模块:署名解析')
['w/csθ'] = true,              -- 单人名, 含斜杠
local norm = parse.norm
['↑=192.333kb/s'] = true,      -- 单人名, 含斜杠
['t+pazolite'] = true,        -- 单人名, 含加号
}


-- ===== 工具 =====
-- ===== 工具 =====
第34行: 第31行:
end
end


local function norm(s)
return (mw.ustring.lower(tostring(s or '')):gsub('%s+', ''))
end
-- 拆分合作者: 先归一化 vs./feat./x 为 '/', 再按分隔符切, 并抽出括号注释
local function splitRaw(raw)
local out = {}
raw = tostring(raw or '')
raw = raw:gsub('%s+[Vv][Ss]%.?%s+', '/'):gsub('%s+[Ff][Ee][Aa][Tt]%.?%s*', '/')
raw = raw:gsub('%s+[Xx]%s+', '/')
for part in mw.text.gsplit(raw, '[/、,,&&%+]') do
part = mw.text.trim(part)
if part ~= '' then
local base, ann = mw.ustring.match(part, '^(.-)%s*[((]([^))]*)[))]')
if base then
table.insert(out, { base = mw.text.trim(base), ann = ann })
else
table.insert(out, { base = part, ann = '' })
end
end
end
return out
end


-- 排序分组: 0=符号/数字 1=拉丁 2=假名 3=汉字 4=其他
-- 排序分组: 0=符号/数字 1=拉丁 2=假名 3=汉字 4=其他
第130行: 第104行:
local raw = song['曲师']
local raw = song['曲师']
if type(raw) == 'table' then raw = raw[1] end
if type(raw) == 'table' then raw = raw[1] end
local parts = NO_SPLIT[norm(raw)] and { { base = raw, ann = '' } } or splitRaw(raw)
local parts = parse.parts(raw)
local seen = {}
local seen = {}
for _, pt in ipairs(parts) do
for _, pt in ipairs(parts) do
第168行: 第142行:
local a = artists[key]
local a = artists[key]
table.insert(out, '\n==' .. esc(a.display) .. '==')
table.insert(out, '\n==' .. esc(a.display) .. '==')
-- 曲目数实时统计(替代此前映射表里无法维护的 _曲目数)
table.insert(out, '<div style="font-size:92%;color:#555">共 ' .. "'''" .. #a.songs .. "'''" .. ' 首曲目</div>')
if a.intro ~= '' then
if a.intro ~= '' then
table.insert(out, a.intro)
table.insert(out, a.intro)
第178行: 第154行:
local notes = {}
local notes = {}
local rawS = type(s['曲师']) == 'table' and s['曲师'][1] or s['曲师']
local rawS = type(s['曲师']) == 'table' and s['曲师'][1] or s['曲师']
local allParts = NO_SPLIT[norm(rawS)] and { { base = rawS, ann = '' } } or splitRaw(rawS)
local allParts = parse.parts(rawS)
for _, pt in ipairs(allParts) do
for _, pt in ipairs(allParts) do
if norm(pt.base) ~= key then table.insert(notes, pt.base) end
if norm(pt.base) ~= key then table.insert(notes, pt.base) end