Test sentiment analysis functionality
()
| 121 | return True |
| 122 | |
| 123 | def test_sentiment_analysis(): |
| 124 | """Test sentiment analysis functionality""" |
| 125 | print("\n🔄 Testing sentiment analysis...") |
| 126 | |
| 127 | from processors.sentiment_analyzer import analyze_sentiment |
| 128 | |
| 129 | test_cases = [ |
| 130 | { |
| 131 | "text": "Emergency evacuation in progress! This is critical!", |
| 132 | "expected_sentiment": "emergency" |
| 133 | }, |
| 134 | { |
| 135 | "text": "Great relief efforts by the volunteers. Thank you!", |
| 136 | "expected_sentiment": "positive" |
| 137 | }, |
| 138 | { |
| 139 | "text": "The damage is devastating. Many people are trapped.", |
| 140 | "expected_sentiment": "negative" |
| 141 | }, |
| 142 | { |
| 143 | "text": "Weather update: Partly cloudy with light winds.", |
| 144 | "expected_sentiment": "neutral" |
| 145 | } |
| 146 | ] |
| 147 | |
| 148 | for i, case in enumerate(test_cases): |
| 149 | result = analyze_sentiment(case["text"]) |
| 150 | print(f" Test {i+1}: '{case['text'][:40]}...'") |
| 151 | print(f" Sentiment: {result['sentiment_label']} (expected: {case['expected_sentiment']})") |
| 152 | print(f" Polarity: {result['polarity']:.2f}") |
| 153 | print(f" Urgency Score: {result['urgency_score']:.2f}") |
| 154 | print(f" Confidence: {result['confidence']:.2f}") |
| 155 | |
| 156 | if result['sentiment_label'] == case['expected_sentiment']: |
| 157 | print(f" ✅ Sentiment analysis correct") |
| 158 | else: |
| 159 | print(f" ⚠️ Sentiment analysis different than expected") |
| 160 | |
| 161 | return True |
| 162 | |
| 163 | def test_data_processing(): |
| 164 | """Test complete data processing pipeline""" |
no test coverage detected