participatory-planner / test_analyzer.py
thadillo
Initial commit: Participatory Planning Application
23654e5
#!/usr/bin/env python3
"""
Quick test script to verify the AI analyzer works correctly.
Run this before starting the app to test the classification.
"""
from app.analyzer import get_analyzer
# Test messages for each category
test_messages = [
("We envision a sustainable city where everyone has access to green spaces", "Vision"),
("Traffic congestion is getting worse every day and causing pollution", "Problem"),
("Our goal is to reduce carbon emissions by 50% by 2030", "Objectives"),
("All new buildings must have solar panels installed", "Directives"),
("We must prioritize environmental sustainability and social equity", "Values"),
("Install bike lanes on Main Street and add bus stops every 500m", "Actions"),
]
def test_analyzer():
print("πŸ€– Testing AI Analyzer...")
print("=" * 60)
# Get analyzer instance
analyzer = get_analyzer()
print("\nπŸ“₯ Loading model (this may take a moment on first run)...\n")
correct = 0
total = len(test_messages)
for message, expected_category in test_messages:
print(f"πŸ“ Message: {message[:60]}...")
# Analyze
predicted_category = analyzer.analyze(message)
# Check result
is_correct = predicted_category == expected_category
symbol = "βœ…" if is_correct else "❌"
print(f" Expected: {expected_category}")
print(f" Got: {predicted_category} {symbol}")
print()
if is_correct:
correct += 1
# Results
accuracy = (correct / total) * 100
print("=" * 60)
print(f"🎯 Results: {correct}/{total} correct ({accuracy:.1f}%)")
if accuracy >= 80:
print("βœ… Analyzer is working well!")
elif accuracy >= 60:
print("⚠️ Analyzer is working but could be better")
else:
print("❌ Analyzer needs improvement")
print("\nπŸ’‘ Tip: The model improves with clearer, more specific messages")
print("=" * 60)
if __name__ == "__main__":
test_analyzer()