def dotest(terms, expected, which): files = filelist(rootdir) terms = words(terms) # print(terms) if which == 0: linear_docs = linear_search(files, terms) # print(filenames(linear_docs)) names = filenames(linear_docs) names.sort() expected.sort() #assert filenames(linear_docs) == expected assert names == expected, "found "+str(names)+" != expected "+str(expected) elif which == 1: index = create_index(files) index_docs = index_search(files, index, terms) # print(filenames(index_docs)) names = filenames(index_docs) names.sort() expected.sort() #assert filenames(index_docs) == expected assert names == expected, "found "+str(names)+" != expected "+str(expected) else: index = myhtable_create_index(files) index_docs = myhtable_index_search(files, index, terms) # print(filenames(index_docs)) names = filenames(index_docs) names.sort() expected.sort() #assert filenames(index_docs) == expected assert names == expected, "found "+str(names)+" != expected "+str(expected)
def test_linear_berlitz_none(): terms = "missspellinnng" files = filelist(rootdir) terms = words(terms) linear_docs = linear_search(files, terms) expected = [] assert filenames(linear_docs)==expected
def test_linear_berlitz(): terms = "hawaii travel" files = filelist(rootdir) terms = words(terms) linear_docs = linear_search(files, terms) expected = ['HistoryHawaii.txt'] assert filenames(linear_docs)==expected
def test_linear_berlitz_none(): terms = "missspellinnng" files = filelist(rootdir) terms = words(terms) linear_docs = linear_search(files, terms) expected = [] assert filenames(linear_docs) == expected
def test_linear_berlitz(): terms = "hawaii travel" files = filelist(rootdir) terms = words(terms) linear_docs = linear_search(files, terms) expected = ['HistoryHawaii.txt'] assert filenames(linear_docs) == expected
def test_myhtable_berlitz(): terms = "hawaii travel" files = filelist(rootdir) terms = words(terms) index = myhtable_create_index(files) myhtable_docs = myhtable_index_search(files, index, terms) expected = ['HistoryHawaii.txt'] assert filenames(myhtable_docs) == expected
def test_myhtable_berlitz_none(): terms = "missspellinnng" files = filelist(rootdir) terms = words(terms) index = myhtable_create_index(files) myhtable_docs = myhtable_index_search(files, index, terms) expected = [] assert filenames(myhtable_docs) == expected