-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fallacy_detection.py
More file actions
47 lines (36 loc) · 1.56 KB
/
test_fallacy_detection.py
File metadata and controls
47 lines (36 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import json
from fallacy_detector import FallacyAnalyzer
from analyzer_ollama import OllamaAnalyzer
from config import config
def test_fallacy_detection():
print("🧪 Starting Fallacy Detection Test Suite...")
analyzer = OllamaAnalyzer(config)
fallacy_detector = FallacyAnalyzer(config, analyzer)
# Load some test cases from inventory
with open('fallacies_inventory.json', 'r', encoding='utf-8') as f:
inventory = json.load(f)
# Pick 5 diverse test cases
test_ids = ["F001", "F041", "F067", "F076", "F081"]
test_cases = [f for f in inventory if f['id'] in test_ids and f['example']]
successes = 0
total = len(test_cases)
for case in test_cases:
print(f"\n📝 Testing {case['id']}: {case['name']}")
print(f"💬 Example: {case['example']}")
# Analyze
result = fallacy_detector.analyze_fallacies(case['example'])
detected_ids = [f['id'] for f in result.get('fallacies', [])]
print(f"🔍 Detected: {detected_ids}")
if case['id'] in detected_ids:
print("✅ SUCCESS: Target fallacy detected.")
successes += 1
else:
print("❌ FAILURE: Target fallacy not detected.")
print(f"Reasoning: {result.get('reasoning', 'N/A')}")
print(f"\n📊 Results: {successes}/{total} ({successes/total*100:.1f}%)")
if __name__ == "__main__":
try:
test_fallacy_detection()
except Exception as e:
print(f"❌ Test failed with error: {e}")
print("Note: This test requires active Ollama and Qdrant services.")