fix(report): fill the full-data edition and clear English Han
Add the interpretation pages from fields the engine already computed, project the annual tables the reader prints, and clear English Han on the four measured charts. Patyayini is not implemented. The generate button copy is unchanged. This commit stays on the feature branch and is not pushed to staging.
This commit is contained in:
@@ -212,6 +212,11 @@ def _sanitize_pl9_ai_density_markdown(markdown: str, title: str = "印度占星
|
||||
text = text.replace("Natural friends", "天然友星")
|
||||
text = text.replace("Natural enemies", "天然敌星")
|
||||
text = text.replace("Temporary relation", "临时关系")
|
||||
text = text.replace("Natal / KP Ruling Planets", "本命 / KP 征象星")
|
||||
text = text.replace("Ruling Planets", "征象星")
|
||||
text = text.replace("Sub-Planets", "副行星")
|
||||
text = text.replace("Planetary", "行星")
|
||||
text = text.replace("Planets", "行星")
|
||||
text = text.replace("Planet", "行星")
|
||||
text = text.replace("Sign", "星座")
|
||||
text = text.replace("Degree in sign", "落座度数")
|
||||
@@ -409,6 +414,9 @@ def _sanitize_pl9_ai_density_markdown(markdown: str, title: str = "印度占星
|
||||
"Divisional Charts Numeric Tables": "分盘数值位置表",
|
||||
"Sensitive Points": "敏感点",
|
||||
"Upagraha and Sub-行星 Points": "Upagraha 与副行星点",
|
||||
"Upagraha and 副行星 Points": "Upagraha 与副行星点",
|
||||
"行星 Friendship Matrix": "行星友敌关系矩阵",
|
||||
"行星 Friendship 矩阵源数据": "行星友敌关系矩阵源数据",
|
||||
"六维力量 Components": "六维力量细项",
|
||||
"Functional 自然吉星 / 自然凶星 Layer": "功能性吉凶星层",
|
||||
"Bhava 年龄状态 宫位 强度": "十二宫力量",
|
||||
@@ -1123,6 +1131,18 @@ def _sanitize_pl9_ai_density_markdown_en(markdown: str, title: str = "Vedic Astr
|
||||
"表达受阻,可能表现为说话不顺、迟疑或难以清楚表达": "speech may be obstructed, hesitant or difficult to express clearly",
|
||||
"思绪容易扰动,需留意情绪、压力与判断稳定性": "the mind may be disturbed; emotional pressure and judgment stability need care",
|
||||
"体型偏瘦,体质较敏感": "leaner body type and sensitive constitution",
|
||||
"水瓶": "Aquarius",
|
||||
"天蝎": "Scorpio",
|
||||
"白羊": "Aries",
|
||||
"摩羯": "Capricorn",
|
||||
"金牛": "Taurus",
|
||||
"双子": "Gemini",
|
||||
"巨蟹": "Cancer",
|
||||
"狮子": "Leo",
|
||||
"处女": "Virgo",
|
||||
"天秤": "Libra",
|
||||
"射手": "Sagittarius",
|
||||
"双鱼": "Pisces",
|
||||
"火": "Mars",
|
||||
"水": "Mercury",
|
||||
"木": "Jupiter",
|
||||
@@ -2110,16 +2130,61 @@ _SITE_BHAVA_SCORE = re.compile(r"\(Benefic\):\s*\+2|\(Malefic\):\s*-1\.5|吉星\
|
||||
_NEECHA_RAJA = re.compile(r"Neecha Bhanga Raja Yoga|落陷取消王瑜伽|坏座位消王")
|
||||
|
||||
|
||||
def _apply_local_report_conventions(markdown: str) -> str:
|
||||
def _apply_local_report_conventions(markdown: str, *, language: str = "zh") -> str:
|
||||
"""Keep this site's report wording inside the upstream appendix."""
|
||||
text = _NEECHA_RAJA.sub("落陷取消(Neecha Bhanga)", markdown)
|
||||
if language == "en":
|
||||
text = _NEECHA_RAJA.sub(
|
||||
"Neecha Bhanga (debilitation cancellation, not a Raja Yoga)",
|
||||
markdown,
|
||||
)
|
||||
text = re.sub(r"\bguaranteed\b", "certain", text, flags=re.IGNORECASE)
|
||||
text = re.sub(r"\bguarantee\b", "certain outcome", text, flags=re.IGNORECASE)
|
||||
text = re.sub(r"\bdivorce\b", "relationship strain", text, flags=re.IGNORECASE)
|
||||
text = re.sub(r"\bmiscarriage\b", "a sensitive health topic", text, flags=re.IGNORECASE)
|
||||
text = re.sub(r"\binfertility\b", "a sensitive fertility topic", text, flags=re.IGNORECASE)
|
||||
else:
|
||||
text = _NEECHA_RAJA.sub("落陷取消(Neecha Bhanga)", markdown)
|
||||
text = text.replace("疾病诊断", "身体负荷话题")
|
||||
text = text.replace("一定会", "有可能")
|
||||
text = re.sub(r"(?<!不是)必然", "可能", text)
|
||||
text = text.replace("再婚", "关系变化")
|
||||
text = text.replace("几段关系", "关系主题")
|
||||
text = text.replace("早夭", "早年体质")
|
||||
text = text.replace("疾病", "身体负荷")
|
||||
text = text.replace("落陷取消王", "落陷取消")
|
||||
text = _SITE_BHAVA_SCORE.sub("", text)
|
||||
return text
|
||||
|
||||
|
||||
def _insert_opening_focus(markdown: str, focus: str) -> str:
|
||||
"""Put the current-period focus directly under the title."""
|
||||
first = next((line.strip() for line in focus.splitlines() if line.strip()), "")
|
||||
if not first or first in markdown:
|
||||
return markdown
|
||||
match = re.search(r"^#\s+.+$", markdown, flags=re.MULTILINE)
|
||||
if not match:
|
||||
return focus.rstrip() + "\n\n" + markdown
|
||||
return markdown[: match.end()] + "\n\n" + focus.rstrip() + "\n" + markdown[match.end() :]
|
||||
|
||||
|
||||
def _interpretation_tools():
|
||||
try:
|
||||
from pl9_interpretation_packs import attach_full_data_interpretation, opening_focus_block
|
||||
except ModuleNotFoundError: # pragma: no cover - package import compatibility
|
||||
from scripts.pl9_interpretation_packs import attach_full_data_interpretation, opening_focus_block
|
||||
return attach_full_data_interpretation, opening_focus_block
|
||||
|
||||
|
||||
def render_full_data_markdown(packet: dict) -> str:
|
||||
"""Upstream `pl9_ai_density` branch at 23be1807, on this site's parity body."""
|
||||
if _pl9_report_language(packet) == "en":
|
||||
attach_full_data_interpretation, opening_focus_block = _interpretation_tools()
|
||||
if isinstance(packet, dict):
|
||||
attach_full_data_interpretation(packet)
|
||||
focus = opening_focus_block(packet)
|
||||
else:
|
||||
focus = ""
|
||||
language = _pl9_report_language(packet if isinstance(packet, dict) else {})
|
||||
if language == "en":
|
||||
structured_appendix = re.sub(
|
||||
r"^#\s+.*?(?:\n{2,}|\n)",
|
||||
"",
|
||||
@@ -2127,7 +2192,7 @@ def render_full_data_markdown(packet: dict) -> str:
|
||||
count=1,
|
||||
flags=re.DOTALL,
|
||||
).strip()
|
||||
english_markdown = render_pl9_parity_markdown(packet)
|
||||
english_markdown = _insert_opening_focus(render_pl9_parity_markdown(packet), focus)
|
||||
if structured_appendix:
|
||||
english_markdown = (
|
||||
english_markdown.rstrip()
|
||||
@@ -2140,7 +2205,7 @@ def render_full_data_markdown(packet: dict) -> str:
|
||||
english_markdown,
|
||||
_pl9_english_report_title(packet),
|
||||
)
|
||||
return _apply_local_report_conventions(rendered)
|
||||
return _apply_local_report_conventions(rendered, language="en")
|
||||
zh_structured_markdown = _sanitize_pl9_ai_density_markdown(
|
||||
_render_pl9_ai_density_raw_data_markdown_en(packet),
|
||||
_pl9_public_report_title(packet),
|
||||
@@ -2152,7 +2217,7 @@ def render_full_data_markdown(packet: dict) -> str:
|
||||
count=1,
|
||||
flags=re.DOTALL,
|
||||
).strip()
|
||||
zh_markdown = render_pl9_parity_markdown(packet)
|
||||
zh_markdown = _insert_opening_focus(render_pl9_parity_markdown(packet), focus)
|
||||
if zh_structured_appendix and "## 结构化资料附录" not in zh_markdown:
|
||||
zh_markdown = (
|
||||
zh_markdown.rstrip()
|
||||
@@ -2162,7 +2227,7 @@ def render_full_data_markdown(packet: dict) -> str:
|
||||
+ "\n\n</details>\n"
|
||||
)
|
||||
rendered = _sanitize_pl9_ai_density_markdown(zh_markdown, _pl9_public_report_title(packet))
|
||||
return _apply_local_report_conventions(rendered)
|
||||
return _apply_local_report_conventions(rendered, language="zh")
|
||||
|
||||
|
||||
def read_full_data_domain(packet: Mapping, domain: str) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user