Update app.py
Browse files
app.py
CHANGED
@@ -1,45 +1,29 @@
|
|
1 |
-
|
2 |
-
import
|
3 |
-
import pygame
|
4 |
|
5 |
-
|
6 |
-
nlp = pipeline("text2text-generation", model="datificate/gpt2-small-spanish")
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
return
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
return "¡Correcto! El verbo está en la oración."
|
18 |
else:
|
19 |
-
return
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
verb = input("Identifica el verbo en la siguiente oración: " + sentence + "\n")
|
34 |
-
|
35 |
-
# Check if the child's answer is correct
|
36 |
-
result = check_answer(sentence, verb)
|
37 |
-
|
38 |
-
# Play sound effect if the answer is correct
|
39 |
-
if "Correcto" in result:
|
40 |
-
sound_effect.play()
|
41 |
-
|
42 |
-
return result
|
43 |
-
|
44 |
-
# Run the chatbot interface using Gradio
|
45 |
-
gr.Interface(fn=chatbot, inputs=None, outputs="text").launch()
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import spacy
|
|
|
3 |
|
4 |
+
nlp = spacy.load('es_core_news_sm')
|
|
|
5 |
|
6 |
+
def identify_pos(sentence):
|
7 |
+
doc = nlp(sentence)
|
8 |
+
pos_tags = [(token.text, token.pos_) for token in doc]
|
9 |
+
return pos_tags
|
10 |
|
11 |
+
def game_logic(sentence, user_input):
|
12 |
+
correct_answers = identify_pos(sentence)
|
13 |
+
if user_input in correct_answers:
|
14 |
+
return True
|
|
|
15 |
else:
|
16 |
+
return False
|
17 |
+
|
18 |
+
def main():
|
19 |
+
st.title('Juego de gramática española')
|
20 |
+
sentence = st.text_input('Introduce una frase:')
|
21 |
+
user_input = st.text_input('Identifica una palabra en la frase:')
|
22 |
+
if sentence and user_input:
|
23 |
+
if game_logic(sentence, user_input):
|
24 |
+
st.success('¡Correcto!')
|
25 |
+
else:
|
26 |
+
st.error('Incorrecto. Intenta de nuevo.')
|
27 |
+
|
28 |
+
if __name__ == "__main__":
|
29 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|