Пример #1
0
# files = files[:100]
N = len(files)
print N, "files"

index = None

while True:
    terms = raw_input("Search terms: ")
    terms = words(terms)

    if impl == 'linear':
        docs = linear_search(files, terms)
    elif impl == 'index':
        if index is None:
            index = create_index(files)
            print "Index complete"
        docs = index_search(files, index, terms)
    elif impl == 'myhtable':
        if index is None:
            index = myhtable_create_index(files)
            print "Index complete"
        docs = myhtable_index_search(files, index, terms)
    else:
        print "Invalid search type:", impl
        break
    page = results(docs, terms)
    f = open("/tmp/results.html", "w")
    f.write(page)
    f.close()
    webbrowser.open_new_tab("file:///tmp/results.html")
Пример #2
0
# Uncomment the next line to test just the first 100 files instead of all files
# files = files[:100]
N = len(files)
print(N, "files")

index = None

while True:
    terms = input("Search terms: ")
    terms = words(terms)

    if impl=='linear':
        docs = linear_search(files, terms)
    elif impl == 'index':
        if index is None:
            index = create_index(files)
            print("Index complete")
        docs = index_search(files, index, terms)
    elif impl == 'myhtable':
        if index is None:
            index = myhtable_create_index(files)
            print("Index complete")
        docs = myhtable_index_search(files, index, terms)
    else:
        print("Invalid search type:", impl)
        break
    page = results(docs, terms)
    with open("/tmp/results.html", "w", encoding='UTF-8') as f:
        f.write(page)
    webbrowser.open_new_tab("file:///tmp/results.html")