MCPcopy Create free account
hub / github.com/ashfawk/oceanhazard-detection / test_hazard_classification

Function test_hazard_classification

test_python_pipeline.py:83–121  ·  view source on GitHub ↗

Test hazard classification functionality

()

Source from the content-addressed store, hash-verified

81 return True
82
83def test_hazard_classification():
84 """Test hazard classification functionality"""
85 print("\n🔄 Testing hazard classification...")
86
87 from processors.classifier import HazardClassifier, classify_post_enhanced
88
89 test_cases = [
90 {
91 "text": "Tsunami warning issued for coastal areas. Evacuate immediately!",
92 "expected_hazard": "Tsunami",
93 "expected_urgency": "high"
94 },
95 {
96 "text": "Heavy rainfall causing flooding in the city",
97 "expected_hazard": "Flooding",
98 "expected_urgency": "medium"
99 },
100 {
101 "text": "Beautiful sunset at the beach today",
102 "expected_hazard": "General",
103 "expected_urgency": "low"
104 }
105 ]
106
107 classifier = HazardClassifier()
108
109 for i, case in enumerate(test_cases):
110 hazard_type, urgency, confidence = classify_post_enhanced(case["text"])
111 print(f" Test {i+1}: '{case['text'][:40]}...'")
112 print(f" Hazard: {hazard_type} (expected: {case['expected_hazard']})")
113 print(f" Urgency: {urgency} (expected: {case['expected_urgency']})")
114 print(f" Confidence: {confidence:.2f}")
115
116 if hazard_type == case["expected_hazard"]:
117 print(f" ✅ Hazard classification correct")
118 else:
119 print(f" ⚠️ Hazard classification different than expected")
120
121 return True
122
123def test_sentiment_analysis():
124 """Test sentiment analysis functionality"""

Callers 1

mainFunction · 0.85

Calls 2

HazardClassifierClass · 0.90
classify_post_enhancedFunction · 0.90

Tested by

no test coverage detected