コード例 #1
0
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)
コード例 #2
0
ファイル: test_berlitz.py プロジェクト: parrt/msan692
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)
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
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
コード例 #7
0
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
コード例 #8
0
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
コード例 #9
0
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
コード例 #10
0
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