Spaces:
Sleeping
Sleeping
Added expanders to results
Browse files
app.py
CHANGED
@@ -102,8 +102,19 @@ def sort_by_rating(k):
|
|
102 |
k - int - how many top-matching places to show
|
103 |
'''
|
104 |
relevance = np.array(st.session_state.precalculated_df['Relevancy'])
|
105 |
-
rating = np.array(
|
106 |
top_similar_by_rating = dict(enumerate(np.multiply(relevance, rating)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
st.session_state.precalculated_df['Sort_rating'] = top_similar_by_rating.values()
|
108 |
|
109 |
#sort in the descending order
|
@@ -113,6 +124,7 @@ def sort_by_rating(k):
|
|
113 |
#get restaurant names
|
114 |
names = [rest_names[i] for i in top_k_similar.keys()]
|
115 |
result = dict(zip(names, top_k_similar.values()))
|
|
|
116 |
return result
|
117 |
|
118 |
#combines 2 users preferences into 1 string and fetches best options
|
@@ -240,9 +252,28 @@ css = """
|
|
240 |
display: inline-block;
|
241 |
padding: 5px 10px;
|
242 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
</style>
|
244 |
"""
|
245 |
|
|
|
246 |
# options_disability_1 = st.multiselect(
|
247 |
# 'Do you need a wheelchair?',
|
248 |
# ['Yes', 'No'], ['No'], key=101)
|
@@ -258,8 +289,9 @@ css = """
|
|
258 |
# with st.form('my_form_1'):
|
259 |
# st.subheader('**User 1**')
|
260 |
|
261 |
-
st.
|
262 |
-
|
|
|
263 |
food_1 = st.selectbox('Select the food type you prefer', st.session_state.food, key=1)
|
264 |
if food_1 == 'Other':
|
265 |
food_1 = st.text_input(label="Your description", placeholder="What kind of food would you like to eat?", key=10)
|
@@ -276,10 +308,9 @@ additional_1 = st.text_input(label="Your description", placeholder="Anything els
|
|
276 |
|
277 |
with_kids = st.checkbox('I will come with kids', key=200)
|
278 |
|
279 |
-
|
280 |
-
st.
|
281 |
|
282 |
-
# Eingabe-Widgets
|
283 |
food_2 = st.selectbox('Select the food type you prefer', st.session_state.food, key=3)
|
284 |
if food_2 == 'Other':
|
285 |
food_2 = st.text_input(label="Your description", placeholder="What kind of food would you like to eat?", key=4)
|
@@ -351,29 +382,36 @@ if submit or (not st.session_state.precalculated_df.empty):
|
|
351 |
|
352 |
condition = st.session_state.precalculated_df['Names'] == name
|
353 |
rating = st.session_state.precalculated_df.loc[condition, 'Rating'].values[0]
|
354 |
-
st.
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
st.
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
i+=1
|
378 |
|
379 |
# st.markdown("This is a text with <span style='font-size: 20px;'>bigger</span> and <i>italic</i> text.", unsafe_allow_html=True)
|
|
|
102 |
k - int - how many top-matching places to show
|
103 |
'''
|
104 |
relevance = np.array(st.session_state.precalculated_df['Relevancy'])
|
105 |
+
rating = np.array(st.session_state.precalculated_df['Rating'])
|
106 |
top_similar_by_rating = dict(enumerate(np.multiply(relevance, rating)))
|
107 |
+
|
108 |
+
## Combine the three lists into a list of tuples (name, score, price)
|
109 |
+
# restaurant_data = list(zip(rest_names, relevance, rating))
|
110 |
+
|
111 |
+
# # Sort the combined list based on rating (index 2) in descending order and relevance (index 1) in descending order
|
112 |
+
# sorted_data = sorted(restaurant_data, key=lambda x: (-x[1], -x[2]))
|
113 |
+
|
114 |
+
# # Extract the sorted lists
|
115 |
+
# sorted_restaurant_names, sorted_relevance, sorted_rating = zip(*sorted_data)
|
116 |
+
# result = {sorted_restaurant_names[i]: sorted_relevance[i] for i in range(k)}
|
117 |
+
|
118 |
st.session_state.precalculated_df['Sort_rating'] = top_similar_by_rating.values()
|
119 |
|
120 |
#sort in the descending order
|
|
|
124 |
#get restaurant names
|
125 |
names = [rest_names[i] for i in top_k_similar.keys()]
|
126 |
result = dict(zip(names, top_k_similar.values()))
|
127 |
+
|
128 |
return result
|
129 |
|
130 |
#combines 2 users preferences into 1 string and fetches best options
|
|
|
252 |
display: inline-block;
|
253 |
padding: 5px 10px;
|
254 |
}
|
255 |
+
|
256 |
+
.violet-box {
|
257 |
+
border: 2px solid #004d00; /* Dark violet contour */
|
258 |
+
border-radius: 10px;
|
259 |
+
background-color: #4CAF50; /* violet background */
|
260 |
+
display: inline-block;
|
261 |
+
padding: 5px 10px;
|
262 |
+
color: #FFFFFF; /* White text color */
|
263 |
+
}
|
264 |
+
|
265 |
+
.violet-box {
|
266 |
+
border: 2px solid #8a2be2; /* Violet contour */
|
267 |
+
border-radius: 10px;
|
268 |
+
background-color: #4169E1; /* Blue background */
|
269 |
+
display: inline-block;
|
270 |
+
padding: 5px 10px;
|
271 |
+
color: #FFFFFF; /* White text color */
|
272 |
+
}
|
273 |
</style>
|
274 |
"""
|
275 |
|
276 |
+
|
277 |
# options_disability_1 = st.multiselect(
|
278 |
# 'Do you need a wheelchair?',
|
279 |
# ['Yes', 'No'], ['No'], key=101)
|
|
|
289 |
# with st.form('my_form_1'):
|
290 |
# st.subheader('**User 1**')
|
291 |
|
292 |
+
st.markdown(css, unsafe_allow_html=True)
|
293 |
+
st.markdown(f'<div class="violet-box">User 1</div>', unsafe_allow_html=True)
|
294 |
+
|
295 |
food_1 = st.selectbox('Select the food type you prefer', st.session_state.food, key=1)
|
296 |
if food_1 == 'Other':
|
297 |
food_1 = st.text_input(label="Your description", placeholder="What kind of food would you like to eat?", key=10)
|
|
|
308 |
|
309 |
with_kids = st.checkbox('I will come with kids', key=200)
|
310 |
|
311 |
+
st.markdown(css, unsafe_allow_html=True)
|
312 |
+
st.markdown(f'<div class="violet-box">User 2</div>', unsafe_allow_html=True)
|
313 |
|
|
|
314 |
food_2 = st.selectbox('Select the food type you prefer', st.session_state.food, key=3)
|
315 |
if food_2 == 'Other':
|
316 |
food_2 = st.text_input(label="Your description", placeholder="What kind of food would you like to eat?", key=4)
|
|
|
382 |
|
383 |
condition = st.session_state.precalculated_df['Names'] == name
|
384 |
rating = st.session_state.precalculated_df.loc[condition, 'Rating'].values[0]
|
385 |
+
with st.expander(f":{nums_emojis[i]}: **{name}** **({str(rating)}**:star:): match score: {score}"):
|
386 |
+
|
387 |
+
#f":{nums_emojis[i]}: **{name}** **({str(rating)}**:star:) :", 'match score:', score
|
388 |
+
try:
|
389 |
+
if type(st.session_state.precalculated_df.loc[condition, 'Price'].values[0]) == str:
|
390 |
+
st.write("Price category:", st.session_state.precalculated_df.loc[condition, 'Price'].values[0])
|
391 |
+
except:
|
392 |
+
pass
|
393 |
+
|
394 |
+
# Use the condition to extract the value(s)
|
395 |
+
# description = st.session_state.precalculated_df.loc[condition, 'Strings']
|
396 |
+
# st.write(description)
|
397 |
+
|
398 |
+
type = [item for item in eval(st.session_state.precalculated_df.loc[condition, 'Category'].values[0])]
|
399 |
+
# Display HTML with the custom styles
|
400 |
+
for word in type:
|
401 |
+
st.markdown(css, unsafe_allow_html=True)
|
402 |
+
st.markdown(f'<div class="blue-box">{word}</div>', unsafe_allow_html=True)
|
403 |
+
# st.write("Restaurant type:", str(type))
|
404 |
+
|
405 |
+
keywords = [item[0] for item in eval(st.session_state.precalculated_df.loc[condition, 'Keywords'].values[0])]
|
406 |
+
for pair in keywords[:3]:
|
407 |
+
st.markdown(css, unsafe_allow_html=True)
|
408 |
+
st.markdown(f'<div class="orange-box">{pair[0]} {pair[1]}</div>', unsafe_allow_html=True)
|
409 |
+
# st.write("Restaurant type:", str(type))
|
410 |
+
|
411 |
+
|
412 |
+
url = st.session_state.precalculated_df.loc[condition, 'URL'].values[0]
|
413 |
+
st.write(f"_Check on the_ [_map_]({url})")
|
414 |
+
|
415 |
i+=1
|
416 |
|
417 |
# st.markdown("This is a text with <span style='font-size: 20px;'>bigger</span> and <i>italic</i> text.", unsafe_allow_html=True)
|