-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecommend_algorithm.py
171 lines (116 loc) · 5.36 KB
/
recommend_algorithm.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import json
def recommend_hotel(data_hotel):
hotelsDictionary = {}
hotelsIDs = {}
for x in range(0, int(data_hotel["paging"]["results"])):
if "ranking_data" in data_hotel["data"][x]:
if data_hotel["data"][x]["ranking_data"] != None:
if "ranking" in data_hotel["data"][x]["ranking_data"]:
if data_hotel["data"][x]["ranking_data"]["ranking"] != None:
ranking = int(data_hotel["data"][x]["ranking_data"]["ranking"])
hotelsDictionary[ranking] = data_hotel["data"][x]["name"]
hotelsIDs[ranking] = x+1
counter = 1
for keys in sorted(hotelsDictionary.keys()):
if counter == 21:
break
print ("Hotel ID: {0:<2}\tRated: #{1:<4}\tName: {2:<50}".format(hotelsIDs[keys], keys, hotelsDictionary[keys]) )
counter += 1
print ()
hotel_choice = int(input("Select a hotel number: "))
print(" Price: {}".format(data_hotel["data"][x-1]["price_level"]))
print ()
confirmation_number = int(input("Confirm Selection number or select again: "))
while hotel_choice != confirmation_number:
hotel_choice = confirmation_number
print(" Price: {}".format(data_hotel["data"][x-1]["price_level"]))
print ()
confirmation_number = int(input("Confirm Selection number or select again: "))
else:
return data_hotel["data"][hotel_choice-1]
def recommend_restaurant(data_restaurant):
print ("\n\n\n")
restaurantsDictionary = {}
restaurantsIDs = {}
for x in range(0, int(data_restaurant["paging"]["results"])):
if "ranking_data" in data_restaurant["data"][x]:
if data_restaurant["data"][x]["ranking_data"] != None:
if "ranking" in data_restaurant["data"][x]["ranking_data"]:
if data_restaurant["data"][x]["ranking_data"]["ranking"] != None:
ranking = int(data_restaurant["data"][x]["ranking_data"]["ranking"])
restaurantsDictionary[ranking] = data_restaurant["data"][x]["name"]
restaurantsIDs[ranking] = x+1
counter = 1
for keys in sorted(restaurantsDictionary.keys()):
if counter == 21:
break
print ("Restaurant ID: {0:<2}\tRated: #{1:<4}\tName: {2:<50}".format(restaurantsIDs[keys], keys, restaurantsDictionary[keys]) )
counter += 1
print ()
x = int(input("Select restaurant number: "))
if x-1 > len(data_restaurant["data"]):
print("Game over")
return 0;
print("Selected: {}".format(data_restaurant["data"][x-1]["name"]) )
print(" Price: {}".format(data_restaurant["data"][x-1]["price_level"]))
for i in range(0, len(data_restaurant["data"][x-1]["cuisine"])):
cuisine = data_restaurant["data"][x-1]["cuisine"][i]["localized_name"]
print(" Cusine {0:<3}.\t{1:<50}".format(i+1, cuisine))
print ()
y = int(input("Confirm Selection number or select again: "))
while x != y:
x = y
if x-1 > len(data_restaurant["data"]):
print("Game over")
return 0;
print("Selected: {}".format(data_restaurant["data"][x-1]["name"]) )
print(" Price: {}".format(data_restaurant["data"][x-1]["price_level"]))
for i in range(0, len(data_restaurant["data"][x-1]["cuisine"])):
cuisine = data_restaurant["data"][x-1]["cuisine"][i]["localized_name"]
print(" Cusine {0:<3}.\t{1:<50}".format(i+1, cuisine))
print ()
y = int(input("Confirm Selection number or select again: "))
return data_restaurant["data"][x-1]
def recommend_attraction(data_attraction):
print("\n\n\n")
attractionsDictionary = {}
attractionsIDs = {}
for x in range(0, int(data_attraction["paging"]["results"])):
if "ranking_data" in data_attraction["data"][x]:
if data_attraction["data"][x]["ranking_data"] != None:
if "ranking" in data_attraction["data"][x]["ranking_data"]:
if data_attraction["data"][x]["ranking_data"]["ranking"] != None:
ranking = int(data_attraction["data"][x]["ranking_data"]["ranking"])
attractionsDictionary[ranking] = data_attraction["data"][x]["name"]
attractionsIDs[ranking] = x+1
counter = 1
for keys in sorted(attractionsDictionary.keys()):
if counter == 21:
break
print ("Attraction ID: {0:<2}\tRated: #{1:<4}\tName: {2:<50}".format(attractionsIDs[keys], keys, attractionsDictionary[keys]) )
counter += 1
print ()
x = int(input("Select Restaurant Number: "))
if x-1 > len(data_attraction["data"]):
print("Game over")
return 0;
print("Selected: {}".format(data_attraction["data"][x-1]["name"]) )
print(" Rating: {}".format(data_attraction["data"][x-1]["rating"]))
for i in range(0, len(data_attraction["data"][x-1]["attraction_types"])):
attraction_types = data_attraction["data"][x-1]["attraction_types"][i]["localized_name"]
print(" Type {0:<3}\t{1:<50}".format(i+1, attraction_types))
print ()
y = int(input("Confirm Selection Number or Reselect: "))
while x != y:
x = y
if x-1 > len(data_attraction["data"]):
print("Game over")
return 0;
print("Selected: {}".format(data_attraction["data"][x-1]["name"]) )
print(" Rating: {}".format(data_attraction["data"][x-1]["rating"]))
for i in range(0, len(data_attraction["data"][x-1]["attraction_types"])):
attraction_types = data_attraction["data"][x-1]["attraction_types"][i]["localized_name"]
print(" Type {0:<3}\t{1:<50}".format(i+1, attraction_types))
print ()
y = int(input("Confirm Selection number or select again: "))
return data_attraction["data"][x-1]