Merlintxu commited on
Commit
be336e7
·
1 Parent(s): 26e934e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -24,6 +24,9 @@ def generate_and_analyze():
24
  sentence_state['tagged_words_es'] = tagged_words_es
25
  return sentence, tagged_words, tagged_words_es
26
 
 
 
 
27
  # The game logic
28
  def game_flow(start_game, *args):
29
  if start_game == 'Empezar':
@@ -33,10 +36,10 @@ def game_flow(start_game, *args):
33
  correct_answer = [tag for _, tag in sentence_state['tagged_words_es']]
34
  user_answer = list(args)
35
  if user_answer == correct_answer:
36
- return sentence_state['sentence'], ' '.join(sentence_state['tagged_words_es']), '¡Correcto!', ''
37
  else:
38
  correction = ' '.join([f'{word} es {tag}' for word, tag in sentence_state['tagged_words_es']])
39
- return sentence_state['sentence'], ' '.join(sentence_state['tagged_words_es']), 'Incorrecto.', 'La respuesta correcta es: ' + correction
40
 
41
  iface = gr.Interface(fn=game_flow,
42
  inputs=[gr.inputs.Textbox(label='Escribe "Empezar" para iniciar el juego')] +
 
24
  sentence_state['tagged_words_es'] = tagged_words_es
25
  return sentence, tagged_words, tagged_words_es
26
 
27
+ # Initialize the game
28
+ generate_and_analyze()
29
+
30
  # The game logic
31
  def game_flow(start_game, *args):
32
  if start_game == 'Empezar':
 
36
  correct_answer = [tag for _, tag in sentence_state['tagged_words_es']]
37
  user_answer = list(args)
38
  if user_answer == correct_answer:
39
+ return sentence_state['sentence'], ' '.join([f'{word} ({tag})' for word, tag in sentence_state['tagged_words_es']]), '¡Correcto!', ''
40
  else:
41
  correction = ' '.join([f'{word} es {tag}' for word, tag in sentence_state['tagged_words_es']])
42
+ return sentence_state['sentence'], ' '.join([f'{word} ({tag})' for word, tag in sentence_state['tagged_words_es']]), 'Incorrecto.', 'La respuesta correcta es: ' + correction
43
 
44
  iface = gr.Interface(fn=game_flow,
45
  inputs=[gr.inputs.Textbox(label='Escribe "Empezar" para iniciar el juego')] +