-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ranking.py
More file actions
24 lines (16 loc) · 860 Bytes
/
Copy pathtest_ranking.py
File metadata and controls
24 lines (16 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from unittest import TestCase
import ranking
class TestTermCount(TestCase):
def test_no_matches(self):
self.assertEqual(0, ranking.term_count(query='t1 t2', document='t3 t4'))
def test_partial_match(self):
self.assertEqual(1, ranking.term_count(query='t1 t2', document='t3 t1'))
def test_repeated_matches(self):
self.assertEqual(5, ranking.term_count(query='t1 t2', document='t1 t3 t2 t1 t2 t2'))
class TestBooleanTermCount(TestCase):
def test_no_matches(self):
self.assertEqual(0, ranking.boolean_term_count(query='t1 t2', document='t3 t4'))
def test_partial_match(self):
self.assertEqual(1, ranking.boolean_term_count(query='t1 t2', document='t3 t1'))
def test_repeated_matches(self):
self.assertEqual(2, ranking.boolean_term_count(query='t1 t2', document='t1 t3 t2 t1 t2 t2'))