Update modules/studentact/current_situation_interface.py
Browse files
modules/studentact/current_situation_interface.py
CHANGED
@@ -61,20 +61,45 @@ def display_current_situation_interface(lang_code, nlp_models, t):
|
|
61 |
# 4. Guardar los resultados
|
62 |
from ..database.current_situation_mongo_db import store_current_situation_result
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
-
#
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
except Exception as e:
|
76 |
-
logger.error(f"Error en
|
77 |
-
st.error(
|
78 |
|
79 |
def display_current_situation_visual(doc, metrics):
|
80 |
"""Visualizaci贸n de resultados"""
|
|
|
61 |
# 4. Guardar los resultados
|
62 |
from ..database.current_situation_mongo_db import store_current_situation_result
|
63 |
|
64 |
+
if st.button(t.get('analyze_button', "Explorar mi escritura")):
|
65 |
+
with st.spinner(t.get('processing', "Analizando texto...")):
|
66 |
+
# Procesar y analizar
|
67 |
+
doc = nlp_models[lang_code](text_input)
|
68 |
+
|
69 |
+
# Obtener m茅tricas con manejo de errores
|
70 |
+
try:
|
71 |
+
metrics = analyze_text_dimensions(doc)
|
72 |
+
except Exception as e:
|
73 |
+
logger.error(f"Error en an谩lisis: {str(e)}")
|
74 |
+
st.error("Error en el an谩lisis de dimensiones")
|
75 |
+
return
|
76 |
|
77 |
+
# Obtener feedback
|
78 |
+
try:
|
79 |
+
feedback = get_claude_feedback(metrics, text_input)
|
80 |
+
except Exception as e:
|
81 |
+
logger.error(f"Error obteniendo feedback: {str(e)}")
|
82 |
+
st.error("Error obteniendo retroalimentaci贸n")
|
83 |
+
return
|
84 |
|
85 |
+
# Guardar resultados con verificaci贸n
|
86 |
+
if store_current_situation_result(
|
87 |
+
st.session_state.username,
|
88 |
+
text_input,
|
89 |
+
metrics,
|
90 |
+
feedback
|
91 |
+
):
|
92 |
+
st.success(t.get('save_success', "An谩lisis guardado"))
|
93 |
+
|
94 |
+
# Mostrar visualizaciones y recomendaciones
|
95 |
+
display_current_situation_visual(doc, metrics)
|
96 |
+
show_recommendations(feedback, t)
|
97 |
+
else:
|
98 |
+
st.error("Error al guardar el an谩lisis")
|
99 |
+
|
100 |
except Exception as e:
|
101 |
+
logger.error(f"Error en interfaz: {str(e)}")
|
102 |
+
st.error("Error general en la interfaz")
|
103 |
|
104 |
def display_current_situation_visual(doc, metrics):
|
105 |
"""Visualizaci贸n de resultados"""
|