-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_not_visual.py
More file actions
45 lines (29 loc) · 1.2 KB
/
main_not_visual.py
File metadata and controls
45 lines (29 loc) · 1.2 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
34
35
36
37
38
39
40
41
42
43
44
45
import json
from pprint import pprint
from src.vectorial.parse_query import create_index_query
from src.parse_directory import get_files_from_path_list
from src.vectorial.parse_document import create_index
from src.vectorial.vectorial_model import calculate_rank
from src.utils import load_index_and_inverse_index, save_index_and_inverse_index
from src.boolean.boolean_model import get_documents
def main():
f = open("files_path.json")
json_files_path = json.load(f)
files = get_files_from_path_list(json_files_path["paths"])
index, inverse_index = create_index(files, verbose=True)
save_index_and_inverse_index(
"results.json", index=index, inverse_index=inverse_index
)
index, inverse_index = load_index_and_inverse_index("results.json")
while True:
# -----Vectorial-----------------
query = input("query: ")
query_index = create_index_query(query)
result = calculate_rank(query_index, index, 3)
pprint(result)
# ------Boolean------------------
query = input("boolean query: ")
result = get_documents(query, inverse_index, set(index.keys()))
pprint(result)
if __name__ == "__main__":
main()