新六章有 12 节读错公开包字段,整节只剩未判定,而且六章绕过了口径替换。按资料包改读路径,先拼六章再统一替换措辞,并把中文附录实际丢掉的组合句数出来。

Co-Authored-By: Grok (agent loop)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jesse-ux
2026-10-22 18:51:54 +08:00
co-authored by Grok (agent loop) Cursor
parent 365b1e647e
commit 92b4e220f2
8 changed files with 647 additions and 135 deletions
+74 -2
View File
@@ -368,6 +368,63 @@ FIELD_ZH = {
"months": "月数",
}
# Names that already had a Chinese header before the #91 fix.
# The annual-table filter used to drop every other column. Counts use this set
# so a later Chinese name still shows up as a column the old filter removed.
ANNUAL_COLUMN_NAMES_BEFORE_FIX = frozenset(FIELD_ZH)
_APPENDIX_DROPS: dict[str, dict[str, int]] = {
"annual_columns": {},
"annual_tables": {},
"effects": {},
"combinations_undetermined": {},
"combinations_replaced": {},
}
def reset_appendix_drop_log() -> None:
"""Clear the per-render drop counts. One Chinese render, then snapshot."""
for bucket in _APPENDIX_DROPS.values():
bucket.clear()
def snapshot_appendix_drop_log() -> dict[str, dict[str, int]]:
return {name: dict(bucket) for name, bucket in _APPENDIX_DROPS.items()}
def note_dropped_annual_column(field: str) -> None:
key = str(field)
bucket = _APPENDIX_DROPS["annual_columns"]
bucket[key] = bucket.get(key, 0) + 1
def note_annual_table() -> None:
bucket = _APPENDIX_DROPS["annual_tables"]
bucket["seen"] = bucket.get("seen", 0) + 1
def _drop_identity(item: dict, text: str) -> str:
parts = [
str(item.get("rule_id") or ""),
str(item.get("source") or ""),
str(item.get("bvr_id") or ""),
str(item.get("name") or ""),
" ".join(str(text).split()),
]
return " | ".join(parts)[:240]
def _note_effect(item: dict, text: str) -> None:
key = _drop_identity(item, text)
bucket = _APPENDIX_DROPS["effects"]
bucket[key] = bucket.get(key, 0) + 1
def _note_combination(item: dict, text: str, kind: str) -> None:
key = _drop_identity(item, text)
bucket = _APPENDIX_DROPS[kind]
bucket[key] = bucket.get(key, 0) + 1
def column_header(field: str, language: str) -> str:
if language != "zh":
@@ -591,12 +648,19 @@ def chinese_yoga_label(item: dict) -> str:
def chinese_combination(item: dict) -> str:
"""Use the Chinese combination sentence. An English sentence is not translated word by word."""
combination = str(item.get("combination") or "").strip()
if combination and re.search(r"[\u4e00-\u9fff]", combination) and not _HAN_FUNCTION_RE.search(combination) and not SIGN_EN_RE.search(combination):
han = bool(re.search(r"[\u4e00-\u9fff]", combination))
function = bool(_HAN_FUNCTION_RE.search(combination)) if combination else False
sign = bool(SIGN_EN_RE.search(combination)) if combination else False
if combination and han and not function and not sign:
return combination
planets = item.get("planets") if isinstance(item.get("planets"), list) else []
names = [planet_name(planet, "zh") for planet in planets if planet]
if names:
if combination:
_note_combination(item, combination, "combinations_replaced")
return "与".join(names)
if combination:
_note_combination(item, combination, "combinations_undetermined")
return "未判定"
@@ -610,7 +674,15 @@ def yoga_cells(item: dict, language: str) -> list[Any]:
category_text = "未判定"
strength = item.get("strength") or "-"
effects = item.get("effects") if isinstance(item.get("effects"), list) else []
kept = [str(effect) for effect in effects if str(effect).strip() and not _has_prose_glue(str(effect))]
kept = []
for effect in effects:
text = str(effect).strip()
if not text:
continue
if _has_prose_glue(text):
_note_effect(item, text)
continue
kept.append(text)
effects_text = ";".join(kept) or "-"
return [chinese_yoga_label(item), category_text, strength, chinese_combination(item), effects_text]