Spaces:
Sleeping
Sleeping
| #!/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() | |