英文漏译改在渲染侧查表,测试不再放行 PyJHora 子进程。
冻结的 jaimini.py 恢复成 staging 原样。缺译单元格写成固定标记,不再留空。 Co-Authored-By: Grok (agent loop) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Grok (agent loop)
Cursor
parent
7876c0b4ac
commit
adfa98bf97
@@ -0,0 +1,62 @@
|
||||
"""Marker for an English report cell that is still Chinese or has no English twin."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
HAN = re.compile(r"[\u4e00-\u9fff]")
|
||||
MISSING_MARK = "[translation missing:"
|
||||
|
||||
|
||||
def translation_missing(field: str) -> str:
|
||||
return f"[translation missing: {field}]"
|
||||
|
||||
|
||||
def _as_text(value: Any) -> str:
|
||||
if value is None:
|
||||
return ""
|
||||
if isinstance(value, (list, tuple)):
|
||||
return " ".join(part for part in (_as_text(item) for item in value) if part)
|
||||
return str(value).strip()
|
||||
|
||||
|
||||
def first_clean_english(*candidates: Any, field: str, chinese: Any = None) -> str:
|
||||
"""First candidate with no Han, or a visible marker.
|
||||
|
||||
Empty English beside an empty Chinese source stays empty. A Han string, or
|
||||
a Chinese source with no clean English candidate, is not blanked out.
|
||||
"""
|
||||
saw_text = False
|
||||
for candidate in candidates:
|
||||
text = _as_text(candidate)
|
||||
if not text:
|
||||
continue
|
||||
saw_text = True
|
||||
if HAN.search(text) is None:
|
||||
return text
|
||||
if saw_text or _as_text(chinese):
|
||||
return translation_missing(field)
|
||||
return ""
|
||||
|
||||
|
||||
def english_effects(effects_en: Any, effects_zh: Any, field: str = "effects") -> list[str]:
|
||||
"""English effect lines. Han lines become one missing-translation marker."""
|
||||
source = effects_en if isinstance(effects_en, list) else []
|
||||
cleaned: list[str] = []
|
||||
dropped_han = False
|
||||
for item in source:
|
||||
text = _as_text(item)
|
||||
if not text:
|
||||
continue
|
||||
if HAN.search(text) is not None:
|
||||
dropped_han = True
|
||||
continue
|
||||
cleaned.append(text)
|
||||
if dropped_han:
|
||||
cleaned.append(translation_missing(field))
|
||||
if cleaned:
|
||||
return cleaned
|
||||
if _as_text(effects_zh) or _as_text(effects_en):
|
||||
return [translation_missing(field)]
|
||||
return []
|
||||
@@ -0,0 +1,16 @@
|
||||
"""English Chara Karaka duties, keyed by karaka name.
|
||||
|
||||
``scripts/jaimini.py`` is a sealed rectification scoring file. English wording
|
||||
for the report is resolved here, at render time, and that file stays unchanged.
|
||||
"""
|
||||
|
||||
KARAKA_DOMAIN_EN = {
|
||||
"Atmakaraka": "soul aim, core self, highest aim",
|
||||
"Amatyakaraka": "career direction, main advisor, delegated authority",
|
||||
"Bhratrikaraka": "siblings, courage, appetite for risk",
|
||||
"Matrikaraka": "mother, home base, emotional security",
|
||||
"Putrakaraka": "children, creativity, students, crafted results",
|
||||
"Gnatikaraka": "rivals, illness, obstacles, capacity for change",
|
||||
"Darakaraka": "spouse traits, partnership, marriage quality",
|
||||
"Pitrukaraka": "father, ancestral pattern, inherited tradition",
|
||||
}
|
||||
Reference in New Issue
Block a user