Spaces:
Sleeping
Sleeping
Changed how matching keywords in results show + removed full description from results
Browse files
app.py
CHANGED
@@ -59,7 +59,8 @@ def compute_cos_sim(input):
|
|
59 |
# for el in st.session_state.preferences_2:
|
60 |
# query += el
|
61 |
|
62 |
-
st.write("Your query
|
|
|
63 |
embedded_query = get_bert_embeddings(query, model, tokenizer)
|
64 |
embedded_query = embedded_query.numpy()
|
65 |
top_similar = np.array([])
|
@@ -180,8 +181,8 @@ def promote_places():
|
|
180 |
a function that takes most common words, checks if descriptions fit them, increases their weight if they do
|
181 |
'''
|
182 |
#punish the weight of places that don't fit restrictions
|
183 |
-
st.write("Here are the most common preferences you provided:")
|
184 |
-
st.write(st.session_state.fixed_preferences)
|
185 |
|
186 |
preferences = st.session_state.fixed_preferences
|
187 |
|
@@ -259,6 +260,9 @@ if 'precalculated_df' not in st.session_state:
|
|
259 |
|
260 |
if 'results' not in st.session_state:
|
261 |
st.session_state.results = {}
|
|
|
|
|
|
|
262 |
|
263 |
# Configure Streamlit page and state
|
264 |
st.title("GoTogether!")
|
@@ -417,6 +421,7 @@ if submit or (not st.session_state.precalculated_df.empty):
|
|
417 |
query = get_combined_preferences(st.session_state.preferences_1, st.session_state.preferences_2)
|
418 |
#sort places based on restrictions
|
419 |
st.session_state.precalculated_df = filter_places(st.session_state.restrictions)
|
|
|
420 |
#sort places by elevating preferrences
|
421 |
|
422 |
st.session_state.precalculated_df = promote_places()
|
@@ -452,8 +457,13 @@ if submit or (not st.session_state.precalculated_df.empty):
|
|
452 |
|
453 |
descr = st.session_state.precalculated_df.loc[condition, 'Strings'].values[0]
|
454 |
for word in set([word.lower() for word in descr.split()]):
|
455 |
-
if word in st.session_state.fixed_preferences:
|
456 |
st.markdown(f'✅{word.capitalize()}')
|
|
|
|
|
|
|
|
|
|
|
457 |
|
458 |
|
459 |
#Restaurant category
|
@@ -478,7 +488,7 @@ if submit or (not st.session_state.precalculated_df.empty):
|
|
478 |
url = st.session_state.precalculated_df.loc[condition, 'URL'].values[0]
|
479 |
st.write(f"_Check on the_ [_map_]({url})")
|
480 |
|
481 |
-
st.write(descr)
|
482 |
|
483 |
i+=1
|
484 |
|
@@ -487,7 +497,7 @@ if submit or (not st.session_state.precalculated_df.empty):
|
|
487 |
|
488 |
|
489 |
st.session_state.preferences_1, st.session_state.preferences_2 = [], []
|
490 |
-
st.session_state.restrictions = []
|
491 |
|
492 |
stop = st.button("New search!", type='primary', key=500)
|
493 |
if stop:
|
@@ -500,4 +510,5 @@ if stop:
|
|
500 |
st.session_state.precalculated_df = pd.DataFrame()
|
501 |
st.session_state.results = {}
|
502 |
st.session_state.fixed_preferences = []
|
|
|
503 |
|
|
|
59 |
# for el in st.session_state.preferences_2:
|
60 |
# query += el
|
61 |
|
62 |
+
# st.write("Your query is", query)
|
63 |
+
# st.write("Your restrictions are", st.session_state.restrictions)
|
64 |
embedded_query = get_bert_embeddings(query, model, tokenizer)
|
65 |
embedded_query = embedded_query.numpy()
|
66 |
top_similar = np.array([])
|
|
|
181 |
a function that takes most common words, checks if descriptions fit them, increases their weight if they do
|
182 |
'''
|
183 |
#punish the weight of places that don't fit restrictions
|
184 |
+
# st.write("Here are the most common preferences you provided:")
|
185 |
+
# st.write(st.session_state.fixed_preferences)
|
186 |
|
187 |
preferences = st.session_state.fixed_preferences
|
188 |
|
|
|
260 |
|
261 |
if 'results' not in st.session_state:
|
262 |
st.session_state.results = {}
|
263 |
+
|
264 |
+
if 'fixed_restrictions' not in st.session_state:
|
265 |
+
st.session_state.fixed_restrictions = []
|
266 |
|
267 |
# Configure Streamlit page and state
|
268 |
st.title("GoTogether!")
|
|
|
421 |
query = get_combined_preferences(st.session_state.preferences_1, st.session_state.preferences_2)
|
422 |
#sort places based on restrictions
|
423 |
st.session_state.precalculated_df = filter_places(st.session_state.restrictions)
|
424 |
+
st.session_state.fixed_restrictions = st.session_state.restrictions
|
425 |
#sort places by elevating preferrences
|
426 |
|
427 |
st.session_state.precalculated_df = promote_places()
|
|
|
457 |
|
458 |
descr = st.session_state.precalculated_df.loc[condition, 'Strings'].values[0]
|
459 |
for word in set([word.lower() for word in descr.split()]):
|
460 |
+
if word in [el.lower() for el in st.session_state.fixed_preferences]:
|
461 |
st.markdown(f'✅{word.capitalize()}')
|
462 |
+
if word in [el.lower() for el in st.session_state.fixed_restrictions]:
|
463 |
+
if word == 'kids':
|
464 |
+
st.markdown(f'✅Good for kids')
|
465 |
+
else:
|
466 |
+
st.markdown(f'✅{word.capitalize()}')
|
467 |
|
468 |
|
469 |
#Restaurant category
|
|
|
488 |
url = st.session_state.precalculated_df.loc[condition, 'URL'].values[0]
|
489 |
st.write(f"_Check on the_ [_map_]({url})")
|
490 |
|
491 |
+
# st.write(descr)
|
492 |
|
493 |
i+=1
|
494 |
|
|
|
497 |
|
498 |
|
499 |
st.session_state.preferences_1, st.session_state.preferences_2 = [], []
|
500 |
+
# st.session_state.restrictions = []
|
501 |
|
502 |
stop = st.button("New search!", type='primary', key=500)
|
503 |
if stop:
|
|
|
510 |
st.session_state.precalculated_df = pd.DataFrame()
|
511 |
st.session_state.results = {}
|
512 |
st.session_state.fixed_preferences = []
|
513 |
+
|
514 |
|