Update app.py
Browse files
app.py
CHANGED
@@ -23,13 +23,14 @@ def identify_pos(sentence: str):
|
|
23 |
def game_logic(sentence: str, user_word: str, user_pos: str):
|
24 |
correct_answers = identify_pos(sentence)
|
25 |
user_pos = pos_map.get(user_pos.lower(), '')
|
26 |
-
for
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
return False, f'
|
|
|
33 |
|
34 |
def generate_hint(sentence: str, user_word: str, user_pos: str):
|
35 |
inputs = tokenizer.encode(f'Give a hint about the {user_pos} in the sentence "{sentence}"', return_tensors='pt')
|
|
|
23 |
def game_logic(sentence: str, user_word: str, user_pos: str):
|
24 |
correct_answers = identify_pos(sentence)
|
25 |
user_pos = pos_map.get(user_pos.lower(), '')
|
26 |
+
word_pos_list = [word_pos for word_pos in correct_answers if word_pos[0] == user_word]
|
27 |
+
if not word_pos_list:
|
28 |
+
return False, f'La palabra "{user_word}" no se encuentra en la frase.'
|
29 |
+
for word, pos in word_pos_list:
|
30 |
+
if pos.lower() == user_pos.lower():
|
31 |
+
return True, f'¡Correcto! "{user_word}" es un {user_pos}.'
|
32 |
+
return False, f'Incorrecto. "{user_word}" no es un {user_pos}, puede ser {", ".join(set(pos for word, pos in word_pos_list))}.'
|
33 |
+
|
34 |
|
35 |
def generate_hint(sentence: str, user_word: str, user_pos: str):
|
36 |
inputs = tokenizer.encode(f'Give a hint about the {user_pos} in the sentence "{sentence}"', return_tensors='pt')
|