DrDomedag commited on
Commit
3207e42
·
1 Parent(s): 9c55106

Added synonym handling to event participation page. Fixed pluralisation.

Browse files
pages/dish_planning.py CHANGED
@@ -34,7 +34,7 @@ with col1:
34
  break
35
 
36
  if allergic_people_count > 0:
37
- st.write(f"{i} - {allergic_people_count} are sensitive to this ingredient")
38
  else:
39
  st.write(f"{i}")
40
 
@@ -60,10 +60,10 @@ with col2:
60
  total_affected_guests = 0
61
  for pool in user_pools.keys():
62
  #relevant_allergies = pool.split(",")
63
- st.write(f"{user_pools[pool]} users cannot eat {pool}")
64
  total_affected_guests += user_pools[pool]
65
 
66
- st.write(f"In total, {total_affected_guests} are unable to eat this dish.")
67
 
68
 
69
  # Text input for the search query
 
34
  break
35
 
36
  if allergic_people_count > 0:
37
+ st.write(f"{i} - {allergic_people_count} guest{'s are' if allergic_people_count > 1 else ' is'} sensitive to this ingredient")
38
  else:
39
  st.write(f"{i}")
40
 
 
60
  total_affected_guests = 0
61
  for pool in user_pools.keys():
62
  #relevant_allergies = pool.split(",")
63
+ st.write(f"{user_pools[pool]} user{'s' if user_pools[pool] == 1 else ''} cannot eat {pool}")
64
  total_affected_guests += user_pools[pool]
65
 
66
+ st.write(f"In total, {total_affected_guests} {'is' if total_affected_guests == 1 else 'are'} unable to eat this dish.")
67
 
68
 
69
  # Text input for the search query
pages/user_1_event_participation.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.allergens import *
3
+ from utils.variables import *
4
+ from utils.event_participation import *
5
+
6
+
7
+ user_id = 1
8
+
9
+ show_event_participation(user_id)
pages/user_2_event_participation.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.allergens import *
3
+ from utils.variables import *
4
+ from utils.event_participation import *
5
+
6
+
7
+ user_id = 2
8
+
9
+ show_event_participation(user_id)
pages/user_3_event_participation.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.allergens import *
3
+ from utils.variables import *
4
+ from utils.event_participation import *
5
+
6
+
7
+ user_id = 3
8
+
9
+ show_event_participation(user_id)
utils/allergens.py CHANGED
@@ -236,6 +236,8 @@ synonym_list = [
236
  for t in synonym_list:
237
  for i in range(1, len(t), 1):
238
  synonyms[t[0]].append(t[i])
 
 
239
  if t[i] not in allergens:
240
  allergens.append(t[i])
241
 
 
236
  for t in synonym_list:
237
  for i in range(1, len(t), 1):
238
  synonyms[t[0]].append(t[i])
239
+ if t[0] not in allergens:
240
+ allergens.append(t[0])
241
  if t[i] not in allergens:
242
  allergens.append(t[i])
243
 
utils/event_participation.py CHANGED
@@ -15,6 +15,13 @@ def show_event_participation(user_id):
15
  if allergen == ingredient:
16
  relevant_allergies.append(ingredient)
17
  #st.write(f"The dish will contain {ingredient}. You are allergic to {ingredient}.⚠️")
 
 
 
 
 
 
 
18
  if len(relevant_allergies) == 0:
19
  st.write("✅You can eat this dish!✅")
20
  else:
 
15
  if allergen == ingredient:
16
  relevant_allergies.append(ingredient)
17
  #st.write(f"The dish will contain {ingredient}. You are allergic to {ingredient}.⚠️")
18
+ else:
19
+ found = False
20
+ for s in synonyms[ingredient]:
21
+ print()
22
+ if s in user_list[user_id].keys():
23
+ relevant_allergies.append(f"{ingredient} ({s})")
24
+ break
25
  if len(relevant_allergies) == 0:
26
  st.write("✅You can eat this dish!✅")
27
  else: