File size: 5,597 Bytes
2885c68
 
 
 
 
b5f3bc2
2885c68
 
 
 
b5f3bc2
2885c68
 
b5f3bc2
 
 
 
 
2885c68
 
 
 
b5f3bc2
2885c68
 
 
 
 
 
b5f3bc2
2885c68
 
 
 
 
 
 
 
 
 
 
 
b5f3bc2
 
 
 
 
 
2885c68
 
 
b5f3bc2
 
 
 
 
2885c68
 
 
 
b5f3bc2
2885c68
 
 
 
 
 
 
 
 
 
b5f3bc2
2885c68
 
 
 
b5f3bc2
2885c68
 
 
 
 
 
 
 
 
 
b5f3bc2
2885c68
 
 
 
b5f3bc2
2885c68
 
 
 
 
 
 
 
 
b5f3bc2
2885c68
 
 
 
b5f3bc2
2885c68
 
 
b5f3bc2
2885c68
 
 
 
 
 
 
 
 
 
b5f3bc2
2885c68
 
d0eb81e
b5f3bc2
d0eb81e
b5f3bc2
 
 
 
2885c68
 
 
 
 
b5f3bc2
d0eb81e
 
 
b5f3bc2
 
 
 
2885c68
 
 
 
 
b5f3bc2
2885c68
 
 
 
d0eb81e
 
 
b5f3bc2
 
 
 
d0eb81e
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
"""
Test suite for classifier module
"""

import pytest
from classifier import AIPapersIntelligenceClassifier


def test_classifier_initialization():
    """Test that classifier initializes correctly"""
    classifier = AIPapersIntelligenceClassifier()
    assert classifier.agi_keywords is not None
    assert classifier.asi_keywords is not None
    assert classifier.aci_keywords is not None
    assert classifier.ani_keywords is not None
    assert classifier.other_ai_keywords is not None
    assert classifier.ml_keywords is not None
    assert classifier.ds_keywords is not None


def test_classifier_with_semantic():
    """Test classifier with semantic analysis enabled"""
    classifier = AIPapersIntelligenceClassifier(use_semantic=True, model_id="keyword")
    assert classifier.use_semantic == True
    assert classifier.model_id == "keyword"


def test_classify_paper():
    """Test paper classification"""
    classifier = AIPapersIntelligenceClassifier()
    
    test_paper = {
        'title': 'Neural Computers: A New Computing Paradigm',
        'summary': 'Researchers propose Neural Computers that unify computation and memory, potentially leading to artificial general intelligence.',
        'full_entry': 'Neural Computers: A New Computing Paradigm - This could be a step toward AGI'
    }
    
    result = classifier.classify_paper(test_paper)
    
    assert 'classification' in result
    assert 'classification_reason' in result
    assert 'asi_score' in result
    assert 'agi_score' in result
    assert 'aci_score' in result
    assert 'ani_score' in result
    assert 'other_ai_score' in result
    assert 'ml_score' in result
    assert 'ds_score' in result
    assert 'combined_score' in result
    assert 'matched_agi_keywords' in result
    assert 'matched_asi_keywords' in result
    assert 'matched_aci_keywords' in result
    assert 'matched_ani_keywords' in result
    assert 'matched_other_ai_keywords' in result
    assert 'matched_ml_keywords' in result
    assert 'matched_ds_keywords' in result


def test_classify_paper_agi():
    """Test classification of AGI paper"""
    classifier = AIPapersIntelligenceClassifier()
    
    agi_paper = {
        'title': 'General Intelligence in AI Systems',
        'summary': 'This paper discusses artificial general intelligence and transfer learning capabilities.',
        'full_entry': 'AGI paper content'
    }
    
    result = classifier.classify_paper(agi_paper)
    
    assert result['agi_score'] >= 1
    assert result['classification'] in ['ASI', 'AGI', 'ACI', 'ANI', 'Other AI', 'ML', 'DS']


def test_classify_paper_asi():
    """Test classification of ASI paper"""
    classifier = AIPapersIntelligenceClassifier()
    
    asi_paper = {
        'title': 'AI Safety and Alignment Problem',
        'summary': 'Analysis of existential risks from superintelligent AI systems and alignment challenges.',
        'full_entry': 'ASI safety paper'
    }
    
    result = classifier.classify_paper(asi_paper)
    
    assert result['asi_score'] >= 1
    assert result['classification'] in ['ASI', 'AGI', 'ACI', 'ANI', 'Other AI', 'ML', 'DS']


def test_classify_paper_not_related():
    """Test classification of non-related paper"""
    classifier = AIPapersIntelligenceClassifier()
    
    unrelated_paper = {
        'title': 'Image Classification with CNNs',
        'summary': 'A standard convolutional neural network for image classification.',
        'full_entry': 'Standard ML paper'
    }
    
    result = classifier.classify_paper(unrelated_paper)
    
    assert result['classification'] in ['ASI', 'AGI', 'ACI', 'ANI', 'Other AI', 'ML', 'DS', 'Not Related']


def test_batch_classify():
    """Test batch classification"""
    classifier = AIPapersIntelligenceClassifier()
    
    papers = [
        {'title': 'AGI Paper', 'summary': 'About general intelligence', 'full_entry': 'AGI'},
        {'title': 'ML Paper', 'summary': 'About machine learning', 'full_entry': 'ML'},
    ]
    
    results = classifier.batch_classify(papers)
    
    assert len(results) == 2
    assert all('classification_result' in p for p in results)


def test_get_statistics():
    """Test statistics calculation"""
    classifier = AIPapersIntelligenceClassifier()
    
    classified_papers = [
        {'classification_result': {'classification': 'ASI'}},
        {'classification_result': {'classification': 'AGI'}},
        {'classification_result': {'classification': 'ACI'}},
        {'classification_result': {'classification': 'ANI'}},
        {'classification_result': {'classification': 'Other AI'}},
        {'classification_result': {'classification': 'ML'}},
        {'classification_result': {'classification': 'DS'}},
        {'classification_result': {'classification': 'Not Related'}},
    ]
    
    stats = classifier.get_statistics(classified_papers)
    
    assert stats['total'] == 8
    assert stats['asi'] == 1
    assert stats['agi'] == 1
    assert stats['aci'] == 1
    assert stats['ani'] == 1
    assert stats['other_ai'] == 1
    assert stats['ml'] == 1
    assert stats['ds'] == 1
    assert stats['not_related'] == 1


def test_get_statistics_empty():
    """Test statistics with empty list"""
    classifier = AIPapersIntelligenceClassifier()
    
    stats = classifier.get_statistics([])
    
    assert stats['total'] == 0
    assert stats['asi'] == 0
    assert stats['agi'] == 0
    assert stats['aci'] == 0
    assert stats['ani'] == 0
    assert stats['other_ai'] == 0
    assert stats['ml'] == 0
    assert stats['ds'] == 0
    assert stats['not_related'] == 0