-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_metrics.py
83 lines (69 loc) · 2.72 KB
/
test_metrics.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
"""
Core test script for cognitive metrics evaluation.
This script provides a focused test environment for validating our metrics,
following British English standards and proper type safety.
"""
import os
import sys
from pathlib import Path
# Add project root to Python path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
def main():
"""Run core validation tests."""
print("Testing Cognitive Metrics Framework")
print("=================================")
try:
# Test imports
print("\nValidating imports...")
import spacy
from src.metrics.cognitive_metrics import ReasoningEvaluator
from src.evaluation_protocols import TestCase, MetricResult
print("✓ Core modules imported successfully")
# Test NLP setup
print("\nValidating NLP setup...")
nlp = spacy.load("en_core_web_sm")
print("✓ English language model loaded")
# Test text processing
test_text = """
First, let's examine the evidence carefully. According to recent studies,
the approach shows promising results in 75% of cases. However, we must
consider some limitations. For example, the sample size was relatively
small. Therefore, while the data suggests positive outcomes, further
validation would be beneficial.
"""
doc = nlp(test_text)
print("✓ Text processing working")
# Test pattern matching
print("\nValidating pattern matching...")
patterns = {
"Logical Steps": ["first", "therefore", "while"],
"Evidence": ["according to", "studies", "data suggests"],
"Counterarguments": ["however", "limitations"]
}
matches = {}
for category, terms in patterns.items():
matches[category] = [
term for term in terms
if term.lower() in test_text.lower()
]
for category, found in matches.items():
if found:
print(f"✓ {category}: Found {len(found)} patterns")
print(f" - {', '.join(found)}")
print("\n✓ All validation tests completed successfully!")
return 0
except ImportError as e:
print(f"\n✗ Import error: {e}")
print("Please ensure all dependencies are installed:")
print("pip install -r requirements.txt")
print("python -m spacy download en_core_web_sm")
return 1
except Exception as e:
print(f"\n✗ Error: {e}")
import traceback
print("\nTraceback:")
traceback.print_exc()
return 1
if __name__ == "__main__":
sys.exit(main())