-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (30 loc) · 1.04 KB
/
main.py
File metadata and controls
33 lines (30 loc) · 1.04 KB
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
from index import index, new_index_of_index, doc_ids, base_directory
from search import search
import os
import time
def load_info():
# load index of index and document ids into memory for search
with open(os.path.join(base_directory, "dids.csv")) as f:
for line in f:
try:
line = line[:-1]
doc_ids[int(line.split(',')[0])] = line.split(',')[1]
except:
continue
with open(os.path.join(base_directory, "index.csv")) as f:
for line in f:
line = line[:-1]
new_index_of_index[line.split(',')[0]] = int(line.split(',')[1])
if __name__ == '__main__':
inp = input("Do you already have an inverted index? y/n\n")
if inp == "n":
start = time.time()
index()
print(time.time()-start)
search()
elif inp == "y":
# Only works if you already have "dids.csv", "index.csv", and "storage.csv"
load_info()
search()
else:
print("Invalid input")