File size: 1,702 Bytes
0859e68 ab3800b 8ecaf5d ab3800b 0859e68 8ecaf5d 0859e68 |
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
#modules/morphosyntax/morphosyntax_process.py
import streamlit as st
from ..text_analysis.morpho_analysis import (
get_repeated_words_colors,
highlight_repeated_words,
generate_arc_diagram,
get_detailed_pos_analysis,
get_morphological_analysis,
get_sentence_structure_analysis,
perform_advanced_morphosyntactic_analysis
)
from ..database.morphosintax_mongo_db import store_student_morphosyntax_result
from ..chatbot.chatbot import process_chat_input
def process_morphosyntactic_input(user_input, lang_code, nlp_models, t):
if user_input.startswith('/analisis_morfosintactico'):
text_to_analyze = user_input.split('[', 1)[1].rsplit(']', 1)[0]
result = perform_advanced_morphosyntactic_analysis(text_to_analyze, nlp_models[lang_code])
if result is None or 'arc_diagrams' not in result:
response = t.get('morphosyntactic_analysis_error', 'Error in morphosyntactic analysis')
return response, None, None
response = t.get('morphosyntactic_analysis_completed', 'Morphosyntactic analysis completed')
visualizations = result['arc_diagrams']
store_student_morphosyntax_result(
st.session_state.username,
text_to_analyze,
visualizations
)
return response, visualizations, result
else:
chatbot = st.session_state.morphosyntax_chat_input
response = chatbot.generate_response(user_input, lang_code)
return response, None, None
def format_analysis_response(result, t, lang_code):
# Formatea la respuesta del análisis en texto legible
# Usa las traducciones (t) para los títulos y etiquetas
# ...
pass |