-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
79 lines (69 loc) · 1.81 KB
/
main.py
File metadata and controls
79 lines (69 loc) · 1.81 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from upload import uploadData
from checkIndex import checkdata
from getDataS import getdata
from getDataID import getdataisbnUid
from dataCluster import clusterData
#MENU
def menu():
options = {
1: option_1,
2: option_2,
3: option_3,
4: option_4,
5: quit
}
while True:
print("Menu:")
print("1. Upload a File to ElasticSearch")
print("2. Check via index")
print("3. Retrieve Data from ElasticSearch")
print("4. Data Cluster")
print("5. Quit")
choice = int(input("Enter your choice: "))
if choice in options:
options[choice]()
else:
print("Invalid choice.")
def option_1():
fname=input("Give the name of File: ")
iname=input("Give the index of File: ")
uploadData(fname, iname)
print(75 * "=")
print("Upload Completed!".center(75))
print(75 * "=")
def option_2():
iname=input("Give the index of File you are searching: ")
checkdata(iname)
def option_3():
keyword = input("Give the keyword: ")
print("1. Search with simply metric")
print("2. Search with uid metric")
choice = int(input("Choice: "))
if choice == 1:
books = getdata('books', keyword)
print('MATCH QUERY METRIC'.center(95, '='))
print(books.loc[:, ['book_title', 'book_author', 'score']])
print(95 * "=")
elif choice == 2:
user = int(input("Give user id: "))
ch = input("Use neural network? [Y/n]: ").lower().strip()
if ch == 'y':
state = True
else:
state = False
books = getdataisbnUid(keyword, user, activate_nn=state)
print('MATCH QUERY METRIC THROUGH USER ID'.center(95, '='))
print(books.loc[:, ['book_title', 'book_author', 'score']])
print(95 * "=")
def option_4():
print('1. Euclidean Distance')
print('2. Cosine Similarity')
ch = int(input('Choice: '))
dist = 'cosine_similarity'
if ch == 1:
dist = 'euclidean_distance'
clusterData(dist)
def quit():
print("Quitting.")
exit()
menu()