"""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