code to be validated.
class AstrologyAnalyzer:
def __init__(self):
# === HOUSE MEANINGS ===
self.house_meanings = {
"H1": ["body", "self", "health", "birth", "personality", "head", "life force"],
"H2": ["wealth", "family", "speech", "food", "face", "right eye", "education early"],
"H3": ["siblings", "courage", "short travel", "arms", "ears", "communication"],
"H4": ["mother", "home", "vehicle", "education", "heart", "chest", "land"],
"H5": ["children", "intelligence", "love", "purva punya", "stomach", "creativity"],
"H6": ["enemy", "disease", "debt", "litigation", "intestine", "pets"],
"H7": ["spouse", "marriage", "business", "partner", "lower abdomen", "sex organs"],
"H8": ["longevity", "sudden events", "inheritance", "occult", "genitals", "chronic disease"],
"H9": ["luck", "father", "dharma", "guru", "long travel", "thighs", "higher education"],
"H10": ["career", "fame", "job", "authority", "knees", "status", "profession"],
"H11": ["gains", "elder sibling", "desire fulfillment", "calves", "left ear"],
"H12": ["loss", "expense", "foreign", "moksha", "bed pleasure", "feet", "sleep", "jail"]
}
# === PLANET MEANINGS ===
self.planet_meanings = {
"SURYA": ["father", "government", "eyes", "soul", "authority", "bones", "heart", "leadership"],
"CHANDRA": ["mother", "mind", "children", "emotions", "water", "blood", "breast", "face", "travel"],
"KUJA": ["land", "brother", "courage", "accident", "surgery", "muscles", "anger", "army", "fire"],
"BHUDA": ["intelligence", "business", "speech", "skin", "nervous system", "aunt", "logic", "writing"],
"GURU": ["children", "wisdom", "guru", "wealth", "male child", "liver", "fat", "teacher"],
"SUKRA": ["wife", "luxury", "vehicle", "arts", "business", "beauty", "semen", "kidney", "dance", "music"],
"SANI": ["job", "delay", "servant", "longevity", "old age", "bones", "teeth", "knees", "grief", "labor"],
"RAHU": ["foreign", "cheating", "poison", "snake", "air travel", "illusion", "obsession"],
"KETU": ["moksha", "loss", "spirituality", "detachment", "occult"]
}
# === CONSTANTS ===
self.GoodOnly = ["H1", "H5", "H9"]
self.BadOnly = ["H3", "H7", "H11"]
self.GoodBad = ["H2", "H4", "H6", "H8", "H10", "H12"]
# === SAMPLE CHART ===
self.chart = {
"H1": ["SURYA+", "GURU+", "BHUDA+", "RAHU-"],
"H2": ["SUKRA+"],
"H3": [],
"H4": ["BHOOMI+"],
"H5": ["MITRA+", "CHANDRA+"],
"H6": ["SANI-"],
"H7": ["KETU-"],
"H8": ["CHITRA-"],
"H9": [],
"H10": ["BHUDA+"],
"H11": [],
"H12": ["KUJA-"]
}
# ===== UTILITY FUNCTIONS =====
def find_related_entities(self, keyword):
"""Find all planets and houses related to a keyword"""
related_planets = [p for p, props in self.planet_meanings.items() if keyword in props]
related_houses = [h for h, props in self.house_meanings.items() if keyword in props]
return related_planets, related_houses
def find_planet_house(self, planet):
"""Find in which house the planet is placed"""
for h, plist in self.chart.items():
for p in plist:
if p.startswith(planet):
return h, p[-1] # e.g., ("H5", "+")
return None, None
# ===== GENERIC CORRELATION LOGIC =====
def analyze_aspect(self, keyword):
planets, houses = self.find_related_entities(keyword)
if not planets and not houses:
return f"No direct planet or house found for '{keyword}'"
results = []
for planet in planets:
house, sign = self.find_planet_house(planet)
if not house:
continue
# Count positive/negative planets in the target house
for target_house in houses:
if target_house not in self.chart:
continue
pos = sum(1 for p in self.chart[target_house] if p.endswith("+"))
neg = sum(1 for p in self.chart[target_house] if p.endswith("-"))
# Count opposite influences around planet’s house
planet_house_list = self.chart[house]
planet_sign = sign
opposite_count = sum(1 for p in planet_house_list if (p.endswith("+") and planet_sign == "-") or (p.endswith("-") and planet_sign == "+"))
# Apply correlation logic
if target_house in self.BadOnly and planet in planets:
results.append((planet, house, "NO", "In bad house"))
elif target_house in self.GoodOnly and planet_sign == "+" and neg == 0 and opposite_count <= 1:
results.append((planet, house, "YES", "Strong positive placement"))
elif neg > pos or opposite_count > 1:
results.append((planet, house, "NO", "Too many opposite influences"))
else:
results.append((planet, house, "MAYBE", "Cannot decide clearly"))
# Summarize decision
positives = [r for r in results if r[2] == "YES"]
negatives = [r for r in results if r[2] == "NO"]
if positives and not negatives:
final = "YES"
elif negatives and not positives:
final = "NO"
else:
final = "CANNOT DECIDE"
return {
"keyword": keyword,
"result": final,
"details": results
}