File size: 782 Bytes
635422f af39961 635422f af39961 635422f af39961 635422f af39961 635422f 7b823d4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import streamlit as st
import spacy
nlp = spacy.load('es_core_news_sm')
def identify_pos(sentence):
doc = nlp(sentence)
pos_tags = [(token.text, token.pos_) for token in doc]
return pos_tags
def game_logic(sentence, user_input):
correct_answers = identify_pos(sentence)
if user_input in correct_answers:
return True
else:
return False
def main():
st.title('Juego de gramática española')
sentence = st.text_input('Introduce una frase:')
user_input = st.text_input('Identifica una palabra en la frase:')
if sentence and user_input:
if game_logic(sentence, user_input):
st.success('¡Correcto!')
else:
st.error('Incorrecto. Intenta de nuevo.')
if __name__ == "__main__":
main()
|