Spaces:
Configuration error
Configuration error
Create geo_engine.py
Browse files- geo_engine.py +54 -0
geo_engine.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from scoring.corpus import corpus_score, corpus_recommendation
|
| 2 |
+
from scoring.structure import structure_score, structure_recommendation
|
| 3 |
+
from scoring.quality import quality_score, quality_recommendation
|
| 4 |
+
from scoring.hygiene import hygiene_score, hygiene_recommendation
|
| 5 |
+
|
| 6 |
+
def compute_full_geo(input_text: str) -> dict:
|
| 7 |
+
"""
|
| 8 |
+
Combine all four scoring modules. Compute:
|
| 9 |
+
- corpus_score (0–100)
|
| 10 |
+
- structure_score (0–100)
|
| 11 |
+
- quality_score (0–100)
|
| 12 |
+
- hygiene_score (0–100)
|
| 13 |
+
- geo_score = average of all four
|
| 14 |
+
- recommendations: dict with four strings
|
| 15 |
+
"""
|
| 16 |
+
# 1. Corpus Presence & Authority
|
| 17 |
+
c_score = corpus_score(input_text)
|
| 18 |
+
c_rec = corpus_recommendation(input_text, c_score)
|
| 19 |
+
|
| 20 |
+
# 2. Extractability & Structure
|
| 21 |
+
s_score = structure_score(input_text)
|
| 22 |
+
s_rec = structure_recommendation(input_text, s_score)
|
| 23 |
+
|
| 24 |
+
# 3. Content Quality & E-E-A-T
|
| 25 |
+
q_score = quality_score(input_text)
|
| 26 |
+
q_rec = quality_recommendation(input_text, q_score)
|
| 27 |
+
|
| 28 |
+
# 4. Technical AI-Crawl Hygiene
|
| 29 |
+
h_score = hygiene_score(input_text)
|
| 30 |
+
h_rec = hygiene_recommendation(input_text, h_score)
|
| 31 |
+
|
| 32 |
+
# Weighted GEO Score (equal 25% each)
|
| 33 |
+
geo_score = int(
|
| 34 |
+
0.25 * c_score +
|
| 35 |
+
0.25 * s_score +
|
| 36 |
+
0.25 * q_score +
|
| 37 |
+
0.25 * h_score
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
recommendations = {
|
| 41 |
+
"corpus": c_rec,
|
| 42 |
+
"structure": s_rec,
|
| 43 |
+
"quality": q_rec,
|
| 44 |
+
"hygiene": h_rec
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
return {
|
| 48 |
+
"corpus_score": c_score,
|
| 49 |
+
"structure_score": s_score,
|
| 50 |
+
"quality_score": q_score,
|
| 51 |
+
"hygiene_score": h_score,
|
| 52 |
+
"geo_score": geo_score,
|
| 53 |
+
"recommendations": recommendations
|
| 54 |
+
}
|