refactor: Improve handling of optional fields and enhance compatibility score calculations

This commit is contained in:
2025-10-15 17:58:31 +00:00
parent 7f924b60ec
commit 0765cca90d
7 changed files with 31 additions and 22 deletions
+23 -16
View File
@@ -95,16 +95,16 @@ class ReportGenerator:
score += weights["stage"]
# Geography match
investor_geo = investor_data.get("geographic_focus", "").lower()
project_geo = project_data.get("location", "").lower()
investor_geo = (investor_data.get("geographic_focus") or "").lower()
project_geo = (project_data.get("location") or "").lower()
if investor_geo and project_geo and investor_geo in project_geo:
score += weights["geography"]
# Check size match
project_valuation = project_data.get("valuation", 0)
check_lower = investor_data.get("check_size_lower", 0)
check_upper = investor_data.get("check_size_upper", float("inf"))
if check_lower <= project_valuation <= check_upper:
check_lower = investor_data.get("check_size_lower") or 0
check_upper = investor_data.get("check_size_upper") or float("inf")
if check_lower and check_upper and check_lower <= project_valuation <= check_upper:
score += weights["check_size"]
# Thesis alignment (simplified)
@@ -151,14 +151,21 @@ class ReportGenerator:
)
# Geography criterion
investor_geo = investor_data.get("geographic_focus", "N/A")
project_geo = project_data.get("location", "N/A")
geo_match = (
"Strong"
if investor_geo.lower() in project_geo.lower()
or project_geo.lower() in investor_geo.lower()
else "Mismatch"
)
investor_geo = investor_data.get("geographic_focus") or "N/A"
project_geo = project_data.get("location") or "N/A"
# Safe comparison handling None values
if investor_geo == "N/A" or project_geo == "N/A":
geo_match = "N/A" if investor_geo == "N/A" and project_geo == "N/A" else "Mismatch"
else:
investor_geo_lower = investor_geo.lower()
project_geo_lower = project_geo.lower()
geo_match = (
"Strong"
if investor_geo_lower in project_geo_lower
or project_geo_lower in investor_geo_lower
else "Mismatch"
)
criteria.append(
{
"name": "Geography",
@@ -170,8 +177,8 @@ class ReportGenerator:
)
# Check Size criterion
check_lower = investor_data.get("check_size_lower", 0)
check_upper = investor_data.get("check_size_upper", 0)
check_lower = investor_data.get("check_size_lower") or 0
check_upper = investor_data.get("check_size_upper") or 0
project_val = project_data.get("valuation", 0)
check_evidence = "N/A"
@@ -184,7 +191,7 @@ class ReportGenerator:
check_match = (
"Perfect"
if check_lower <= project_val <= check_upper
if check_lower and check_upper and check_lower <= project_val <= check_upper
else "Strong"
if project_val > 0
else "N/A"