Commit 367d197c authored by TP SDA's avatar TP SDA
Browse files

Update test_IndexInverse.py

parent cf210ff5
Pipeline #3157 passed with stage
in 36 seconds
......@@ -11,68 +11,38 @@ from IndexInverse import IndexInverse
from unittest import TestCase
class TestIndexInverse(TestCase):
index = IndexInverse()
index.ajout_url('lipn.fr_1', 'I love shanghai')
index.ajout_url('lipn.fr_2', 'i am from shanghai now i study in tongji university')
index.ajout_url('lipn.fr_3', 'i am from lanzhou now i study in lanzhou university of science and technolgy')
index.create_index()
def test_IndexInverse_1(self):
index1 = IndexInverse()
index1.ajout_url('lipn.fr_1', 'I love shanghai')
index1.ajout_url('lipn.fr_2', 'i am from shanghai now i study in tongji university')
index1.ajout_url('lipn.fr_3', 'i am from lanzhou now i study in lanzhou university of science and technolgy')
index1.create_index()
result = index1.get_docs_with_keyword('i')
result = TestIndexInverse.index.get_docs_with_keyword('i')
self.assertEqual(result, [0,1,2])
def test_IndexInverse_2(self):
index2 = IndexInverse()
index2.ajout_url('lipn.fr_1', 'I love shanghai')
index2.ajout_url('lipn.fr_2', 'i am from shanghai now i study in tongji university')
index2.ajout_url('lipn.fr_3', 'i am from lanzhou now i study in lanzhou university of science and technolgy')
index2.create_index()
result = index2.get_docs_with_keyword('like')
result = TestIndexInverse.index.get_docs_with_keyword('like')
self.assertEqual(result, -1)
def test_IndexInverse_3(self):
index3 = IndexInverse()
index3.ajout_url('lipn.fr_1', 'I love shanghai')
index3.ajout_url('lipn.fr_2', 'i am from shanghai now i study in tongji university')
index3.ajout_url('lipn.fr_3', 'i am from lanzhou now i study in lanzhou university of science and technolgy')
index3.create_index()
result = index3.get_nb_documents()
result = TestIndexInverse.index.get_nb_documents()
self.assertEqual(result, 3)
def test_IndexInverse_4(self):
index4 = IndexInverse()
index4.ajout_url('lipn.fr_1', 'I love shanghai')
index4.ajout_url('lipn.fr_2', 'i am from shanghai now i study in tongji university')
index4.ajout_url('lipn.fr_3', 'i am from lanzhou now i study in lanzhou university of science and technolgy')
index4.create_index()
result = index4.get_nb_vocabularys()
result = TestIndexInverse.index.get_nb_vocabularys()
self.assertEqual(result, 15)
def test_IndexInverse_5(self):
index5 = IndexInverse()
index5.ajout_url('lipn.fr_1', 'I love shanghai')
index5.ajout_url('lipn.fr_2', 'i am from shanghai now i study in tongji university')
index5.ajout_url('lipn.fr_3', 'i am from lanzhou now i study in lanzhou university of science and technolgy')
index5.create_index()
result = index5.get_vocabulary()
result = TestIndexInverse.index.get_vocabulary()
self.assertEqual(result, {'i': 0, 'love': 1, 'shanghai': 2, 'am': 3, 'from': 4, 'now': 5, 'study': 6, 'in': 7, 'tongji': 8,
'university': 9, 'lanzhou': 10, 'of': 11, 'science': 12, 'and': 13, 'technolgy': 14})
def test_IndexInverse_6(self):
index6 = IndexInverse()
index6.ajout_url('lipn.fr_1', 'I love shanghai')
index6.ajout_url('lipn.fr_2', 'i am from shanghai now i study in tongji university')
index6.ajout_url('lipn.fr_3', 'i am from lanzhou now i study in lanzhou university of science and technolgy')
index6.create_index()
result = index6.get_document_id()
result = TestIndexInverse.index.get_document_id()
self.assertEqual(result, {0: 'lipn.fr_1', 1: 'lipn.fr_2', 2: 'lipn.fr_3'})
def test_IndexInverse_7(self):
index7 = IndexInverse()
index7.ajout_url('lipn.fr_1', 'I love shanghai')
index7.ajout_url('lipn.fr_2', 'i am from shanghai now i study in tongji university')
index7.ajout_url('lipn.fr_3', 'i am from lanzhou now i study in lanzhou university of science and technolgy')
index7.create_index()
result = index7.get_docs_content()
result = TestIndexInverse.index.get_docs_content()
self.assertEqual(result, {0: ['i', 'love', 'shanghai'], 1: ['i','am','from', 'shanghai', 'now', 'i', 'study', 'in', 'tongji', 'university'],2: ['i', 'am', 'from', 'lanzhou', 'now', 'i', 'study', 'in', 'lanzhou', 'university', 'of', 'science', 'and', 'technolgy']})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment