-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (33 loc) · 1.05 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from Indexer import *
from QueryProcessor import QueryProcessor
import numpy as np
import math
import time
from nltk.stem import PorterStemmer
from string import ascii_lowercase
if __name__ == "__main__":
index = Indexer()
#index.start_index()
query = input("Enter query: ")
start_time = time.time() #Return the time to start the search
qp = QueryProcessor()
urlid = qp.search(query.lower())
temp = []
if not urlid:
print('no url find with given query')
else:
with open('doc_id.json', 'r') as url_id:
url_dict = json.load(url_id, strict=False)
index = 1
for i in urlid:
try:
if index > 20:
break
result_str = "#%3d: %s" %(index,url_dict[str(i)])
print(result_str)
index += 1
except:
pass
total_time = time.time() - start_time #The total time used to complete the search
time_str = "The search took time %f seconds" % (total_time)
print(time_str)