mirror of
https://github.com/migatu/astrololo.git
synced 2026-07-14 21:38:37 +00:00
82809665ff
- abbreviations.py: słownik skrót -> pełna nazwa (z SIGNIFICATORS KEY, built-in) + expand(): [Su in [Tau -> "Sun in Taurus", [Sa in 6th H. -> "...6th house", affl. -> afflicted itd. - significators: każda próbka ma pole "expanded" (postać czytelna); hartowanie filtra szumu (efekty zastępcze x/?/-, wiersze *MARKER, legendy/nagłówki). - prezentacja /interpret: pokazuje rozwiniętą postać, surowy skrót w tooltipie. Zweryfikowano na realnym main_base.xlsx: "[Sa or [Ma in the 5th H." -> "Saturn or Mars in the 5th house". 9 testów przechodzi (w tym test_abbreviations). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
59 lines
2.3 KiB
Python
59 lines
2.3 KiB
Python
"""Rozwijanie skrótów sygnifikatorów do postaci czytelnej (na bazie SIGNIFICATORS KEY).
|
|
|
|
W bazie zapis jest skrótowy z prefiksem `[` (np. `[Su in [Tau`, `[Sa [conj [Su in 6th H.`).
|
|
Ten moduł zamienia go na tekst czytelny: „Sun in Taurus", „Saturn conjunction Sun
|
|
in 6th house". Słownik pochodzi z pliku SIGNIFICATORS KEY (mały, stabilny — wpięty
|
|
jako built-in; można rozszerzać).
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
|
|
# skrót (bez nawiasu) -> pełna nazwa
|
|
ABBREVIATIONS: dict[str, str] = {
|
|
# znaki zodiaku
|
|
"Ari": "Aries", "Tau": "Taurus", "Gem": "Gemini", "Can": "Cancer",
|
|
"Leo": "Leo", "Vir": "Virgo", "Lib": "Libra", "Sco": "Scorpio",
|
|
"Sag": "Sagittarius", "Cap": "Capricorn", "Aqu": "Aquarius", "Pis": "Pisces",
|
|
# planety klasyczne + światła
|
|
"Su": "Sun", "Mo": "Moon", "Me": "Mercury", "Ve": "Venus",
|
|
"Ma": "Mars", "Ju": "Jupiter", "Sa": "Saturn",
|
|
# planety nowożytne
|
|
"Ur": "Uranus", "Ne": "Neptune", "Pl": "Pluto",
|
|
# węzły i punkty
|
|
"NN": "North Node", "SN": "South Node", "Lilith": "Lilith", "Chiron": "Chiron",
|
|
# osie
|
|
"Asc": "Ascendant", "Dsc": "Descendant", "MC": "Midheaven", "IC": "Imum Coeli",
|
|
# aspekty
|
|
"conj": "conjunction", "sex": "sextile", "sq": "square", "tri": "trine",
|
|
"opp": "opposition", "semisex": "semisextile", "semisq": "semisquare",
|
|
"sesquisq": "sesquisquare", "quincunx": "quincunx", "asp": "aspect",
|
|
# domy jako tokeny [h1..[h12
|
|
**{f"h{i}": f"{i}th house" for i in range(1, 13)},
|
|
# ruch
|
|
"Rx": "retrograde", "R": "retrograde",
|
|
}
|
|
# poprawki nieregularnych liczebników domów
|
|
ABBREVIATIONS.update({"h1": "1st house", "h2": "2nd house", "h3": "3rd house"})
|
|
|
|
# rozwinięcia słów spoza składni `[`
|
|
_WORDS = {
|
|
"affl.": "afflicted",
|
|
"P. Dec.": "parallel of declination",
|
|
"espec.": "especially",
|
|
}
|
|
|
|
_TOKEN = re.compile(r"\[([A-Za-z]+)")
|
|
_HOUSE = re.compile(r"(\d+(?:st|nd|rd|th))\s*H\.", re.IGNORECASE)
|
|
|
|
|
|
def expand(text: str) -> str:
|
|
"""Zamienia skróty na pełne nazwy; nieznane tokeny zostawia bez nawiasu."""
|
|
if not text:
|
|
return text
|
|
out = _TOKEN.sub(lambda m: ABBREVIATIONS.get(m.group(1), m.group(1)), text)
|
|
out = _HOUSE.sub(lambda m: f"{m.group(1)} house", out)
|
|
for k, v in _WORDS.items():
|
|
out = out.replace(k, v)
|
|
return out
|