Files
Jyotisha/scripts/report_render/yoga_appendix_fields.py
T
ClaudeandClaude Opus 5.5 3aae50940e
Independent Staging Quality Gate / publish (push) Canceled after 0s
Independent Staging Quality Gate / validate-frontend (push) Canceled after 31s
Independent Staging Quality Gate / validate-python (push) Canceled after 37s
fix(report): render-only items from the astrologer's 11-25 comparison (BUG-2377–2386)
- 2377 appendix yoga table: kind, formation, also-needs, condition and meaning source (book title only)
- 2378 Saham trace: A, B, C, A − B + C, arc test, +30°, final value
- 2379 daridra_2 「第二宫主落陷…」 no longer classified as Neecha Bhanga
- 2380 Neecha variant names on page titles; Raja add-on line
- 2381 Pancha Mahapurusha page agrees with its basis; degree, Moolatrikona, same-fact line
- 2382 no book/page "Source:" lines in the body Yoga Expression chapter
- 2383 yoga pages state participants' combustion, Shadbala, functional role
- 2384 unresolved-rule records stay backstage (packet only)
- 2385 Neecha verified state matches the row's own fallen planet
- 2386 no hedge line for uncomputed Neecha notes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXp3RzgZVEpT1PXxkwHj
2026-11-25 18:04:38 +08:00

100 lines
5.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""BUG-2377 (占星师 2026-11-25 M01 / M02 / M05; M08's unresolved rules stay backstage, BUG-2384): per-yoga fields for the appendix yoga table.
The detector already returns, per row, what kind of statement it is, whether the rule's conditions are all met,
which inputs were missing, and where the condition and the meaning come from. The appendix table showed only
name, category and planet. These helpers turn those fields into reader words.
Sources follow the owner's rules: only in appendix data chapters (2026-11-24), book title only — no page, PDF
page, line number or table number (BUG-2129), no software library names (BUG-2115).
"""
from __future__ import annotations
import re
from typing import Any
KIND_WORDS = {
"named_yoga_candidate": ("具名格局", "Named yoga"),
"structural_observation": ("结构观察", "Structural observation"),
}
FORMATION_WORDS = {
"conditions_met": ("规则条件都满足", "All rule conditions met"),
"incomplete_conditions": ("部分条件满足", "Some conditions met"),
"method_requires_review": ("不计为成立(判法不止一种)", "Not counted as formed (more than one way to judge it)"),
}
_MISSING_WORDS = {
"source_admitted_composite_strength_profile": ("综合强弱的判法", "a way to judge overall strength"),
"source_admitted_favourable_position_profile": ("「有利位置」的判法", "a way to judge a favourable position"),
"neechamsa_scope_and_referents_source_choice": ("落陷分区的判断范围", "the scope of the debilitated division"),
"benefic_amsa_source_scope": ("吉星分区的判断范围", "the scope of a benefic division"),
"saturn_d3_dispositor": ("土星在 D3 的定位星", "Saturn's dispositor in D3"),
}
_MISSING_DEFAULT = ("规则用到的另一项输入", "another input the rule uses")
_PLANETS_ZH = {"Sun": "太阳", "Moon": "月亮", "Mars": "火星", "Mercury": "水星", "Jupiter": "木星", "Venus": "金星",
"Saturn": "土星", "Rahu": "罗睺", "Ketu": "计都"}
# Book titles a source string may name, in reader words. Anything else is a local rule with no named source.
_BOOKS = (
(re.compile(r"Three Hundred Important Combinations|^BVR-|^Raman\d|^B\.V\. Raman|^Raman,"), ("B.V. Raman《三百个重要组合》", "B.V. Raman, Three Hundred Important Combinations")),
(re.compile(r"Light on Life"), ("《Light on Life》", "Light on Life")),
(re.compile(r"PVR Integrated Approach|Integrated Approach"), ("P.V.R. Narasimha Rao《Vedic Astrology: An Integrated Approach》", "P.V.R. Narasimha Rao, Vedic Astrology: An Integrated Approach")),
(re.compile(r"^BPHS$"), ("《BPHS》", "BPHS")),
(re.compile(r"Phaladeepika|Phaladipika"), ("《Phaladeepika》", "Phaladeepika")),
(re.compile(r"^经典$"), ("经典文献", "classical texts")),
)
_NO_SOURCE = ("本地结构规则,没有具名出处", "local structural rule; no named source")
_NOT_LISTED = ("—", "—")
def _pick(pair: tuple[str, str], language: str) -> str:
return pair[0] if language == "zh" else pair[1]
def kind_text(row: dict, language: str) -> str:
return _pick(KIND_WORDS.get(str(row.get("claim_kind")), _NOT_LISTED), language)
def formation_text(row: dict, language: str) -> str:
assessment = row.get("formation_assessment") if isinstance(row.get("formation_assessment"), dict) else {}
if assessment.get("status") == "formed_under_source":
return "按具名定义成立" if language == "zh" else "Formed under the named definition"
return _pick(FORMATION_WORDS.get(str(row.get("formation_status")), _NOT_LISTED), language)
def missing_text(row: dict, language: str) -> str:
items = [item for item in row.get("missing_inputs") or [] if isinstance(item, str) and item]
if not items:
return "—"
words = []
for item in items:
owner, _, key = item.rpartition(".")
text = _pick(_MISSING_WORDS.get(key, _MISSING_DEFAULT), language)
if owner in _PLANETS_ZH:
text = f"{_PLANETS_ZH[owner]}:{text}" if language == "zh" else f"{owner}: {text}"
if text not in words:
words.append(text)
return (";" if language == "zh" else "; ").join(words)
def source_text(value: Any, language: str) -> str:
"""The book a source string names, without pages or line numbers; a local rule says so."""
if not isinstance(value, str) or not value.strip():
return "—"
text = value.strip()
for pattern, pair in _BOOKS:
if pattern.search(text):
return _pick(pair, language)
return _pick(_NO_SOURCE, language)
def condition_source(row: dict, language: str) -> str:
return source_text(row.get("source_reference") or row.get("source"), language)
def meaning_source(row: dict, language: str) -> str:
if row.get("meaning_source_reference"):
return source_text(row.get("meaning_source_reference"), language)
# The rule entry carries its own meaning: same place as the condition.
if row.get("traditional_effects") or row.get("effects"):
return "同条件出处" if language == "zh" else "same as condition source"
return "—"