schlenker commited on
Commit
ff58dee
·
1 Parent(s): 85e4579

button bug fix

Browse files
Files changed (1) hide show
  1. app.py +69 -2
app.py CHANGED
@@ -124,7 +124,7 @@ def ask_if_helped():
124
  write_bot("I am happy to help!")
125
  elif n:
126
  st.session_state.actions.append('cue')
127
- cue_generation()
128
  elif new:
129
  write_bot("Please describe your word!")
130
  # st.session_state.is_helpful['ask'] = False
@@ -278,13 +278,80 @@ if st.session_state.actions[-1] == "result":
278
  #write_bot(f'The first letter is {st.session_state.results["results"][0][0]}.')
279
  #time.sleep(1)
280
  st.session_state.actions.append('cue')
281
- cue_generation()
282
  #write_bot('Does it help you remember the word?', remember=False)
283
  #st.session_state.is_helpful['ask'] = True
284
 
285
  if st.session_state.is_helpful['ask']:
286
  ask_if_helped()
287
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  # elif prompt == 'results':
289
  # st.text("results")
290
  # st.write("results")
 
124
  write_bot("I am happy to help!")
125
  elif n:
126
  st.session_state.actions.append('cue')
127
+ #cue_generation()
128
  elif new:
129
  write_bot("Please describe your word!")
130
  # st.session_state.is_helpful['ask'] = False
 
278
  #write_bot(f'The first letter is {st.session_state.results["results"][0][0]}.')
279
  #time.sleep(1)
280
  st.session_state.actions.append('cue')
281
+ #cue_generation()
282
  #write_bot('Does it help you remember the word?', remember=False)
283
  #st.session_state.is_helpful['ask'] = True
284
 
285
  if st.session_state.is_helpful['ask']:
286
  ask_if_helped()
287
 
288
+ if st.session_state.actions[-1] == 'cue':
289
+ guessed = False
290
+ write_bot('What do you want to see?', remember=False, blink=False)
291
+
292
+ while guessed == False:
293
+ b1 = st.button("Next letter", key="1")
294
+ b2 = st.button("Next word", key="2")
295
+
296
+ # JS
297
+ word_count = st.session_state.counters["word_count"]
298
+ target = st.session_state.results["results"][word_count]
299
+ if get_available_cues(target):
300
+ avail_cues = get_available_cues(target)
301
+ cues_buttons = {}
302
+ for cue_type, cues in avail_cues.items():
303
+ #st.button(cue_type)
304
+ cues_buttons[cue_type] = st.button(cue_type)
305
+
306
+ b3 = st.button("All words", key="3")
307
+ b4 = st.button("I remembered the word!", key="4", type='primary')
308
+ b5 = st.button("Exit", key="5", type='primary')
309
+
310
+ if b1:
311
+ st.session_state.counters["letter_count"] += 1
312
+ word_count = st.session_state.counters["word_count"]
313
+ letter_count = st.session_state.counters["letter_count"]
314
+ write_bot(f'The word starts with {st.session_state.results["results"][word_count][:letter_count]}', remember=False)
315
+
316
+ elif b2:
317
+ st.session_state.counters["letter_count"] = 1
318
+ letter_count = st.session_state.counters["letter_count"]
319
+ st.session_state.counters["word_count"] += 1
320
+ word_count = st.session_state.counters["word_count"]
321
+ write_bot(f'The next word starts with {st.session_state.results["results"][word_count][:letter_count]}', remember=False)
322
+
323
+ elif "Synonyms" in cues_buttons and cues_buttons['Synonyms']:
324
+ write_bot(f'Here are synonyms for the current word: {", ".join(avail_cues["Synonyms"])}', remember=False)
325
+
326
+ elif "Hypernyms" in cues_buttons and cues_buttons['Hypernyms']:
327
+ write_bot(f'Here are hypernyms for the current word: {", ".join(avail_cues["Hypernyms"])}', remember=False)
328
+
329
+ elif "Hyponyms" in cues_buttons and cues_buttons['Hyponyms']:
330
+ write_bot(f'Here are hyponyms for the current word: {", ".join(avail_cues["Hyponyms"])}', remember=False)
331
+
332
+ elif "Examples" in cues_buttons and cues_buttons['Examples']:
333
+ write_bot(f'Here are example contexts for the current word: {", ".join(avail_cues["Examples"])}', remember=False)
334
+
335
+ elif b3:
336
+ write_bot(f"Here are all my guesses about your word: {st.session_state.results['results_print']}")
337
+
338
+ elif b4:
339
+ write_bot("Yay! I am happy I could be of help!")
340
+ new = st.button('Play again', key=63)
341
+ if new:
342
+ write_bot("Please describe your word!")
343
+ guessed = True
344
+
345
+ break
346
+
347
+ elif b5:
348
+ write_bot("I am sorry I couldn't help you this time. See you soon!")
349
+ st.session_state.actions.append('cue')
350
+ new = st.button('Play again', key=64)
351
+ if new:
352
+ write_bot("Please describe your word!")
353
+ break
354
+
355
  # elif prompt == 'results':
356
  # st.text("results")
357
  # st.write("results")