Spaces:
Sleeping
Sleeping
button arrangement
Browse files
app.py
CHANGED
@@ -182,16 +182,15 @@ def get_available_cues(target):
|
|
182 |
available_cues = {}
|
183 |
synset_target = wn.synsets(target, pos=wn.NOUN)[0]
|
184 |
|
185 |
-
if wn.synonyms(target)[0]:
|
186 |
-
|
187 |
-
#available_cues['Synonyms'] = [word.split('.')[0] if word[0] != "." else word.split('.')[1] for word in wn.synonyms(target)[0]]
|
188 |
|
189 |
-
if synset_target.hypernyms():
|
190 |
-
|
191 |
|
192 |
|
193 |
-
if synset_target.hyponyms():
|
194 |
-
|
195 |
|
196 |
if synset_target.examples():
|
197 |
examples = []
|
@@ -299,65 +298,65 @@ if st.session_state.actions[-1] == 'cue':
|
|
299 |
write_bot('What do you want to see?', remember=False, blink=False)
|
300 |
|
301 |
while guessed == False:
|
302 |
-
col1, col2, col3, col4
|
|
|
|
|
303 |
with col1:
|
304 |
b1 = st.button("Next letter", key="1")
|
305 |
with col2:
|
306 |
-
b2 = st.button("
|
|
|
|
|
|
|
|
|
|
|
307 |
|
308 |
# JS
|
309 |
word_count = st.session_state.counters["word_count"]
|
310 |
target = st.session_state.results["results"][word_count]
|
311 |
-
if get_available_cues(target):
|
312 |
-
|
313 |
-
cues_buttons = {cue_type: st.button(cue_type) for cue_type in avail_cues}
|
314 |
-
#for cue_type in avail_cues:
|
315 |
-
# cues_buttons[cue_type] = st.button(cue_type)
|
316 |
|
317 |
-
with col3:
|
318 |
-
b3 = st.button("All words", key="3")
|
319 |
-
with col4:
|
320 |
-
b4 = st.button("I remembered the word!", key="4", type='primary')
|
321 |
with col5:
|
322 |
-
b5 = st.button("
|
|
|
|
|
323 |
|
324 |
-
b6 = st.button("Related words")
|
325 |
|
326 |
if b1:
|
327 |
st.session_state.counters["letter_count"] += 1
|
328 |
word_count = st.session_state.counters["word_count"]
|
329 |
letter_count = st.session_state.counters["letter_count"]
|
330 |
write_bot(f'The word starts with {st.session_state.results["results"][word_count][:letter_count]}', remember=False)
|
331 |
-
|
332 |
elif b2:
|
|
|
|
|
|
|
|
|
333 |
st.session_state.counters["letter_count"] = 1
|
334 |
letter_count = st.session_state.counters["letter_count"]
|
335 |
st.session_state.counters["word_count"] += 1
|
336 |
word_count = st.session_state.counters["word_count"]
|
337 |
write_bot(f'The next word starts with {st.session_state.results["results"][word_count][:letter_count]}', remember=False)
|
338 |
|
339 |
-
elif get_available_cues(target) and "Synonyms" in cues_buttons and cues_buttons['Synonyms']:
|
340 |
-
write_bot(f'Here are synonyms for the current word: {", ".join(avail_cues["Synonyms"])}', remember=False)
|
341 |
|
342 |
-
elif get_available_cues(target) and "Hypernyms" in cues_buttons and cues_buttons['Hypernyms']:
|
343 |
-
write_bot(f'Here are hypernyms for the current word: {", ".join(avail_cues["Hypernyms"])}', remember=False)
|
344 |
|
345 |
-
elif get_available_cues(target) and "Hyponyms" in cues_buttons and cues_buttons['Hyponyms']:
|
346 |
-
write_bot(f'Here are hyponyms for the current word: {", ".join(avail_cues["Hyponyms"])}', remember=False)
|
347 |
|
348 |
-
elif get_available_cues(target) and "Examples" in cues_buttons and cues_buttons['Examples']:
|
349 |
-
write_bot(f'Here are example contexts for the current word: {", ".join(avail_cues["Examples"])}', remember=False)
|
350 |
|
351 |
-
elif
|
352 |
write_bot(f"Here are all my guesses about your word: {st.session_state.results['results_print']}")
|
353 |
|
354 |
-
elif
|
355 |
-
sent = f"It is related to '{target}' but not '{target}'."
|
356 |
-
rels = return_top_k(st.session_state.descriptions[-1], word=target, rels=True)
|
357 |
-
|
358 |
-
write_bot(f'Here are words that are related to your word: {", ".join(rels)}')
|
359 |
-
|
360 |
-
elif b4:
|
361 |
write_bot("Yay! I am happy I could be of help!")
|
362 |
new = st.button('Play again', key=63)
|
363 |
if new:
|
@@ -366,7 +365,7 @@ if st.session_state.actions[-1] == 'cue':
|
|
366 |
|
367 |
break
|
368 |
|
369 |
-
elif
|
370 |
write_bot("I am sorry I couldn't help you this time. See you soon!")
|
371 |
st.session_state.actions.append('cue')
|
372 |
new = st.button('Play again', key=64)
|
|
|
182 |
available_cues = {}
|
183 |
synset_target = wn.synsets(target, pos=wn.NOUN)[0]
|
184 |
|
185 |
+
#if wn.synonyms(target)[0]:
|
186 |
+
# available_cues['Synonyms'] = postproc_wn(wn.synonyms(target)[0], syns=True)
|
|
|
187 |
|
188 |
+
#if synset_target.hypernyms():
|
189 |
+
# available_cues['Hypernyms'] = postproc_wn(synset_target.hypernyms())
|
190 |
|
191 |
|
192 |
+
#if synset_target.hyponyms():
|
193 |
+
# available_cues['Hyponyms'] = postproc_wn(synset_target.hyponyms())
|
194 |
|
195 |
if synset_target.examples():
|
196 |
examples = []
|
|
|
298 |
write_bot('What do you want to see?', remember=False, blink=False)
|
299 |
|
300 |
while guessed == False:
|
301 |
+
col1, col2, col3, col4 = st.columns(4)
|
302 |
+
col5, col6 = st.columns(2)
|
303 |
+
|
304 |
with col1:
|
305 |
b1 = st.button("Next letter", key="1")
|
306 |
with col2:
|
307 |
+
b2 = st.button("Related words")
|
308 |
+
with col3:
|
309 |
+
b3 = st.button("Next word", key="2")
|
310 |
+
|
311 |
+
with col4:
|
312 |
+
b4 = st.button("All words", key="3")
|
313 |
|
314 |
# JS
|
315 |
word_count = st.session_state.counters["word_count"]
|
316 |
target = st.session_state.results["results"][word_count]
|
317 |
+
#if get_available_cues(target):
|
318 |
+
# avail_cues = get_available_cues(target)
|
319 |
+
#cues_buttons = {cue_type: st.button(cue_type) for cue_type in avail_cues}
|
|
|
|
|
320 |
|
|
|
|
|
|
|
|
|
321 |
with col5:
|
322 |
+
b5 = st.button("I remembered the word!", key="4", type='primary')
|
323 |
+
with col6:
|
324 |
+
b6 = st.button("Exit", key="5", type='primary')
|
325 |
|
|
|
326 |
|
327 |
if b1:
|
328 |
st.session_state.counters["letter_count"] += 1
|
329 |
word_count = st.session_state.counters["word_count"]
|
330 |
letter_count = st.session_state.counters["letter_count"]
|
331 |
write_bot(f'The word starts with {st.session_state.results["results"][word_count][:letter_count]}', remember=False)
|
332 |
+
|
333 |
elif b2:
|
334 |
+
rels = return_top_k(st.session_state.descriptions[-1], word=target, rels=True)
|
335 |
+
write_bot(f'Here are words that are related to your word: {", ".join(rels)}')
|
336 |
+
|
337 |
+
elif b3:
|
338 |
st.session_state.counters["letter_count"] = 1
|
339 |
letter_count = st.session_state.counters["letter_count"]
|
340 |
st.session_state.counters["word_count"] += 1
|
341 |
word_count = st.session_state.counters["word_count"]
|
342 |
write_bot(f'The next word starts with {st.session_state.results["results"][word_count][:letter_count]}', remember=False)
|
343 |
|
344 |
+
#elif get_available_cues(target) and "Synonyms" in cues_buttons and cues_buttons['Synonyms']:
|
345 |
+
#write_bot(f'Here are synonyms for the current word: {", ".join(avail_cues["Synonyms"])}', remember=False)
|
346 |
|
347 |
+
#elif get_available_cues(target) and "Hypernyms" in cues_buttons and cues_buttons['Hypernyms']:
|
348 |
+
#write_bot(f'Here are hypernyms for the current word: {", ".join(avail_cues["Hypernyms"])}', remember=False)
|
349 |
|
350 |
+
#elif get_available_cues(target) and "Hyponyms" in cues_buttons and cues_buttons['Hyponyms']:
|
351 |
+
#write_bot(f'Here are hyponyms for the current word: {", ".join(avail_cues["Hyponyms"])}', remember=False)
|
352 |
|
353 |
+
#elif get_available_cues(target) and "Examples" in cues_buttons and cues_buttons['Examples']:
|
354 |
+
#write_bot(f'Here are example contexts for the current word: {", ".join(avail_cues["Examples"])}', remember=False)
|
355 |
|
356 |
+
elif b4:
|
357 |
write_bot(f"Here are all my guesses about your word: {st.session_state.results['results_print']}")
|
358 |
|
359 |
+
elif b5:
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
write_bot("Yay! I am happy I could be of help!")
|
361 |
new = st.button('Play again', key=63)
|
362 |
if new:
|
|
|
365 |
|
366 |
break
|
367 |
|
368 |
+
elif b6:
|
369 |
write_bot("I am sorry I couldn't help you this time. See you soon!")
|
370 |
st.session_state.actions.append('cue')
|
371 |
new = st.button('Play again', key=64)
|