From 073c35126d30c45e9e48d114593e067de5bb1d52 Mon Sep 17 00:00:00 2001 From: zizi Date: Thu, 16 Jul 2026 01:50:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=86=E6=9E=B6:=20=E7=AB=8B=E5=8D=A1?= =?UTF-8?q?=E8=B7=AF=E8=A1=A5=E5=AE=88=E5=8D=AB(=E5=88=9D=E5=8D=A1?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=8B=86=E5=88=86/=E5=89=A5=E5=89=8D?= =?UTF-8?q?=E7=BC=80/=E5=9E=83=E5=9C=BE=E6=8B=A6=E6=88=AA)+=E5=89=8D?= =?UTF-8?q?=E7=BC=80=E6=AD=A3=E5=88=99=E6=94=BE=E5=AE=BD=E8=87=B3=E7=AB=A0?= =?UTF-8?q?=E5=8F=B7=E8=8C=83=E5=9B=B4=E5=8F=98=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../parse-book/scripts/parse_upgrade.py | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.claude/skills/parse-book/scripts/parse_upgrade.py b/.claude/skills/parse-book/scripts/parse_upgrade.py index c2756f4..bdc4c56 100644 --- a/.claude/skills/parse-book/scripts/parse_upgrade.py +++ b/.claude/skills/parse-book/scripts/parse_upgrade.py @@ -251,8 +251,9 @@ def _strip_prefix(s): import re as _re global WIN_PREFIX_RE if WIN_PREFIX_RE is None: - # [窗…]/[本窗…] 任意变体全剥(窗29实测模型自造 "[窗本窗]",仅数字版剥不掉) - WIN_PREFIX_RE = _re.compile(r"^(?:\[[窗本][^\]]{0,6}\]\s*)+") + # [窗…]/[本窗…] 任意变体全剥(窗29实测模型自造 "[窗本窗]",仅数字版剥不掉; + # 深空实测又造 "[窗387-388]" 章号范围变体,7 字符超旧上限 6——放宽到 12) + WIN_PREFIX_RE = _re.compile(r"^(?:\[[窗本][^\]]{0,12}\]\s*)+") return WIN_PREFIX_RE.sub("", str(s)).strip() @@ -425,10 +426,26 @@ def new_card(conn, work_id, win_no, ent): note = _clean_alias(m.group(2)) if note: extra_alias.append(note) + # 初卡字段过守卫(深空 4917 实测:立卡路不走 merge_card,粘连/自造前缀/垃圾 + # 原样入库——更新路守了、立卡路漏了):列表值逐条拆分、剥前缀、垃圾拦截、带窗号 + fields0 = {} + for k, v in (ent.get("字段", {}) or {}).items(): + if not isinstance(v, list): + fields0[k] = v + continue + out, seen = [], set() + for it in v: + for seg in re.split(r";\s*(?=\[[窗本])", str(it)): + core = _strip_prefix(seg) + if not core or _is_garbage(core) or core in seen: + continue + out.append(f"[窗{win_no}] {core}") + seen.add(core) + fields0[k] = out payload = {"type": ent["型"], "名称": raw, "别名": [x for x in ([_clean_alias(a) for a in ent.get("别名", [])] + extra_alias) if x], "一句话摘要": ent.get("一句话摘要", ""), - "字段": ent.get("字段", {}) or {}, + "字段": fields0, "出场章": sorted(set(ent.get("出场章", []))), "来源": f"升格@窗{win_no}", "状态": "草稿", "目标库": "本书作品库", "可见范围": "本书私有",