The English personal report was discarded whenever a Chinese fragment survived the trailing glossary. English sections now render the English fields that were already calculated. Co-Authored-By: Grok (agent loop) Co-authored-by: Cursor <cursoragent@cursor.com>
149 lines
6.7 KiB
Python
149 lines
6.7 KiB
Python
"""Source English for the leaks named in issue #89. Fictional inputs only."""
|
||
from __future__ import annotations
|
||
|
||
import re
|
||
|
||
from scripts.muhurta import calc_panchanga
|
||
from scripts.narayana_legacy_label import (
|
||
DIRECTION_EN,
|
||
STRENGTH_LEVEL_EN,
|
||
rath_report_lines_en,
|
||
rath_report_lines_zh,
|
||
rath_summary_line_zh,
|
||
)
|
||
from scripts.pl9_reader_export import render_pl9_parity_markdown
|
||
from scripts.yogas_doshas import calc_kaal_sarp_dosha, calc_sade_sati
|
||
from scripts.yoga_engine import STRENGTH_EN
|
||
|
||
HAN = re.compile(r"[㐀-鿿豈-]")
|
||
|
||
|
||
def _rath_view(*, level: int, direction: str, with_divergence: bool) -> dict:
|
||
rule_en = "Ketu in the MD sign: reversed (Table 14)"
|
||
direction_block = {
|
||
"rule_text": "大运星座有计都:反向(Table 14)",
|
||
"rule_text_en": rule_en,
|
||
"direction": "reverse",
|
||
"book_divergence": [
|
||
{
|
||
"rule_text": "p.47(J.S. 1.1.34)看大运星座奇偶",
|
||
"rule_text_en": "p.47 (J.S. 1.1.34) by the odd/even of the MD sign",
|
||
"direction": "zodiacal",
|
||
}
|
||
] if with_divergence else [],
|
||
}
|
||
return {
|
||
"seed_sign": "Libra",
|
||
"strength_level_decided": level,
|
||
"strength_level_text": {1: "占据星数", 5: "宫主星座内度数"}.get(level, f"级别{level}"),
|
||
"strength_level_text_en": STRENGTH_LEVEL_EN[level],
|
||
"direction": direction,
|
||
"direction_text": {key: "计都在起运宫:反向(Table 12)" for key in DIRECTION_EN}.get(direction, "中文顺序"),
|
||
"direction_text_en": DIRECTION_EN[direction],
|
||
"mahadasha": [{
|
||
"sign": "Libra", "lord": "Venus", "start_age": 0, "end_age": 7,
|
||
"base_years": 7, "dignity_adjustment": 0, "years": 7,
|
||
}],
|
||
"current_dasha": {"md": {"sign": "Libra", "lord": "Venus"}},
|
||
"current_md_antardasha": [{"sign": "Libra", "start_age": 0, "end_age": 0.5}],
|
||
"current_md_antardasha_rule": {
|
||
"compared": ["Libra", "Aries"],
|
||
"stronger_sign": "Libra",
|
||
"strength_level_decided": level,
|
||
"lord": "Venus",
|
||
"start_sign": "Libra",
|
||
"direction": direction_block,
|
||
},
|
||
}
|
||
|
||
|
||
def test_rath_english_lines_cover_levels_tables_and_book_divergence() -> None:
|
||
before = rath_summary_line_zh({"seed_sign": "Libra", "strength_level_decided": 5, "strength_level_text": "宫主星座内度数"})
|
||
for level in range(1, 8):
|
||
for direction in ("table10_general", "table11_saturn_zodiacal", "table12_ketu_reversed"):
|
||
view = _rath_view(level=level, direction=direction, with_divergence=True)
|
||
lines = "\n".join(rath_report_lines_en(view))
|
||
assert not HAN.search(lines)
|
||
assert "house " not in lines
|
||
assert f"level {level}: {STRENGTH_LEVEL_EN[level]}" in lines
|
||
assert DIRECTION_EN[direction] in lines
|
||
assert "the book itself disagrees, not applied:" in lines
|
||
ketu = "\n".join(rath_report_lines_en(_rath_view(level=5, direction="table12_ketu_reversed", with_divergence=True)))
|
||
assert "level 5: lord's degree in sign" in ketu
|
||
assert "Ketu in the start sign: reversed (Table 12)" in ketu
|
||
assert rath_summary_line_zh({"seed_sign": "Libra", "strength_level_decided": 5, "strength_level_text": "宫主星座内度数"}) == before
|
||
zh = "\n".join(rath_report_lines_zh(_rath_view(level=5, direction="table12_ketu_reversed", with_divergence=True)))
|
||
assert "- 并列:" in zh and "计都在起运宫:反向(Table 12)" in zh
|
||
|
||
|
||
def test_panchanga_overall_quality_keeps_chinese_and_adds_english() -> None:
|
||
seen = {}
|
||
for sun in range(0, 360, 12):
|
||
for moon in range(0, 360, 15):
|
||
row = calc_panchanga(float(sun), float(moon), 3, 6.0)
|
||
seen[row["overall_quality"]] = row["overall_quality_en"]
|
||
assert row["overall_quality"] in {"吉(Subha)", "中(Mixed)", "凶(Asubha)"}
|
||
assert seen == {
|
||
"吉(Subha)": "Auspicious (Subha)",
|
||
"中(Mixed)": "Mixed",
|
||
"凶(Asubha)": "Inauspicious (Asubha)",
|
||
}
|
||
|
||
|
||
def _planets(houses: dict[str, int]) -> dict:
|
||
return {name: {"house": house, "sign": "Aries"} for name, house in houses.items()}
|
||
|
||
|
||
def test_kaal_sarp_english_summaries_count_planets_in_words() -> None:
|
||
names = ("Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn")
|
||
full = _planets({name: 1 + (index % 6) for index, name in enumerate(names)})
|
||
full["Rahu"] = {"house": 1, "sign": "Aries"}
|
||
full["Ketu"] = {"house": 7, "sign": "Libra"}
|
||
full_row = calc_kaal_sarp_dosha(full)
|
||
assert full_row["summary"].startswith("完全Kaal Sarp Dosha")
|
||
assert full_row["summary_en"] == "Full Kaal Sarp Dosha — all 7 planets lie between the Rahu (1)-Ketu axis"
|
||
assert not HAN.search(full_row["summary_en"])
|
||
|
||
partial = _planets({name: (1 if index < 5 else 8) for index, name in enumerate(names)})
|
||
partial["Rahu"] = {"house": 1, "sign": "Aries"}
|
||
partial["Ketu"] = {"house": 7, "sign": "Libra"}
|
||
partial_row = calc_kaal_sarp_dosha(partial)
|
||
assert partial_row["summary"].startswith("部分Kaal Sarp Dosha")
|
||
assert partial_row["summary_en"] == "Partial Kaal Sarp Dosha — 5 of 7 planets lie between the axis"
|
||
assert "condition planets" not in partial_row["summary_en"]
|
||
|
||
none = _planets({name: 8 for name in names})
|
||
none["Rahu"] = {"house": 1, "sign": "Aries"}
|
||
none["Ketu"] = {"house": 7, "sign": "Libra"}
|
||
none_row = calc_kaal_sarp_dosha(none)
|
||
assert none_row["summary"] == "无Kaal Sarp Dosha"
|
||
assert none_row["summary_en"] == "No Kaal Sarp Dosha"
|
||
|
||
|
||
def test_sade_sati_english_summary_has_no_glued_words() -> None:
|
||
row = calc_sade_sati("Leo")
|
||
assert row["summary"].startswith("Sade Sati阶段框架:")
|
||
assert "judge from Saturn's actual position whether it is underway" in row["summary_en"]
|
||
assert not HAN.search(row["summary_en"])
|
||
for glued in ("atpresent", "whetherinunderway", "withSaturn"):
|
||
assert glued not in row["summary_en"]
|
||
|
||
|
||
def test_punarphoo_strength_column_uses_english() -> None:
|
||
packet = {
|
||
"report_language": "en",
|
||
"worksheets": {"advanced_systems": {"yoga": {"detected_yogas": [{
|
||
"name": "Punarphoo Yoga",
|
||
"category": "relationship_observation",
|
||
"strength": "观察",
|
||
"strength_en": "observational",
|
||
"combination": "月亮与土星合相",
|
||
"combination_en": "Moon conjunct Saturn",
|
||
"effects_en": ["Watch the relationship"],
|
||
}]}}},
|
||
}
|
||
text = render_pl9_parity_markdown(packet)
|
||
assert "| Punarphoo Yoga | relationship_observation | observational | Moon conjunct Saturn |" in text
|
||
assert "观察" not in text
|
||
assert STRENGTH_EN["观察"] == "Watch"
|