Spaces:
Sleeping
Sleeping
Include wordnet relations test
Browse files
app.py
CHANGED
|
@@ -146,10 +146,55 @@ if st.session_state.actions[-1] == "result":
|
|
| 146 |
if st.session_state.is_helpful['ask'] == True:
|
| 147 |
ask_if_helped()
|
| 148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
if st.session_state.actions[-1] == 'cue':
|
| 151 |
guessed = False
|
| 152 |
write_bot('What do you want to see?', remember=False, blink=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
b1 = st.button("Next letter", key="1")
|
| 154 |
b2 = st.button("Next word", key="2")
|
| 155 |
b3 = st.button("All words", key="3")
|
|
|
|
| 146 |
if st.session_state.is_helpful['ask'] == True:
|
| 147 |
ask_if_helped()
|
| 148 |
|
| 149 |
+
# JS
|
| 150 |
+
def postproc_wn(related_words):
|
| 151 |
+
related_words = [word.name().split('.')[0] if word.name()[0] != "." else word.name().split('.')[1] for word in related_words]
|
| 152 |
+
related_words = [word.replace("_", " ") for word in related_words]
|
| 153 |
+
|
| 154 |
+
return related_words
|
| 155 |
+
|
| 156 |
+
# JS
|
| 157 |
+
def get_available_cues(target):
|
| 158 |
+
wn_nouns = [word.name() for word in wn.all_synsets(pos='n')]
|
| 159 |
+
wn_nouns = [word.split('.')[0] if word[0] != "." else word.split('.')[1] for word in wn_nouns]
|
| 160 |
+
|
| 161 |
+
if target in wn_nouns:
|
| 162 |
+
available_cues = {}
|
| 163 |
+
synset_target = wn.synsets(target, pos=wn.NOUN)[0]
|
| 164 |
+
|
| 165 |
+
if wn.synonyms(target):
|
| 166 |
+
available_cues['Synonyms'] = [word.split('.')[0] if word[0] != "." else word.split('.')[1] for word in wn.synonyms(target)[0]]
|
| 167 |
+
|
| 168 |
+
if synset_target.hypernyms():
|
| 169 |
+
available_cues['Hypernyms'] = postproc_wn(synset_target.hypernyms())
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
if synset_target.hyponyms():
|
| 173 |
+
available_cues['Hyponyms'] = postproc_wn(synset_target.hyponyms())
|
| 174 |
+
|
| 175 |
+
if synset_target.examples():
|
| 176 |
+
examples = []
|
| 177 |
+
|
| 178 |
+
for example in synset_target.examples():
|
| 179 |
+
examples.append(example.replace(target, "..."))
|
| 180 |
+
|
| 181 |
+
available_cues['Examples'] = examples
|
| 182 |
+
|
| 183 |
+
return available_cues
|
| 184 |
+
|
| 185 |
+
else:
|
| 186 |
+
return None
|
| 187 |
|
| 188 |
if st.session_state.actions[-1] == 'cue':
|
| 189 |
guessed = False
|
| 190 |
write_bot('What do you want to see?', remember=False, blink=False)
|
| 191 |
+
# JS
|
| 192 |
+
if get_available_cues():
|
| 193 |
+
avail_cues = get_available_cues()
|
| 194 |
+
cues_buttons = []
|
| 195 |
+
for cue_type, cues in avail_cues.items():
|
| 196 |
+
st.button(cue_type)
|
| 197 |
+
|
| 198 |
b1 = st.button("Next letter", key="1")
|
| 199 |
b2 = st.button("Next word", key="2")
|
| 200 |
b3 = st.button("All words", key="3")
|