Update modules/studentact/current_situation_interface.py
Browse files
modules/studentact/current_situation_interface.py
CHANGED
@@ -16,60 +16,61 @@ def display_current_situation_interface(lang_code, nlp_models, t):
|
|
16 |
nlp_models: Diccionario de modelos de spaCy cargados
|
17 |
t: Diccionario de traducciones
|
18 |
"""
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
# Bot贸n de an谩lisis
|
36 |
-
if st.button(
|
37 |
-
t.get('analyze_button', "Explorar mi escritura"),
|
38 |
-
type="primary",
|
39 |
-
disabled=not text_input,
|
40 |
-
key=generate_unique_key("current_situation", "analyze")
|
41 |
-
):
|
42 |
with st.spinner(t.get('processing', "Analizando texto...")):
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
text_input,
|
62 |
-
metrics,
|
63 |
-
feedback
|
64 |
-
):
|
65 |
-
st.success(t.get('save_success', "An谩lisis guardado exitosamente"))
|
66 |
-
|
67 |
-
# 5. Mostrar recomendaciones
|
68 |
-
show_recommendations(feedback, t)
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
73 |
|
74 |
def show_recommendations(feedback, t):
|
75 |
"""
|
|
|
16 |
nlp_models: Diccionario de modelos de spaCy cargados
|
17 |
t: Diccionario de traducciones
|
18 |
"""
|
19 |
+
st.markdown("## Mi Situaci贸n Actual de Escritura")
|
20 |
+
|
21 |
+
# Container principal para mejor organizaci贸n visual
|
22 |
+
with st.container():
|
23 |
+
# Columnas para entrada y visualizaci贸n
|
24 |
+
text_col, visual_col = st.columns([1,2])
|
25 |
|
26 |
+
with text_col:
|
27 |
+
# 脕rea de entrada de texto
|
28 |
+
text_input = st.text_area(
|
29 |
+
t.get('current_situation_input', "Ingresa tu texto para analizar:"),
|
30 |
+
height=400,
|
31 |
+
key=generate_unique_key("current_situation", "input")
|
32 |
+
)
|
33 |
|
34 |
+
# Bot贸n de an谩lisis
|
35 |
+
if st.button(
|
36 |
+
t.get('analyze_button', "Explorar mi escritura"),
|
37 |
+
type="primary",
|
38 |
+
disabled=not text_input,
|
39 |
+
key=generate_unique_key("current_situation", "analyze")
|
40 |
+
):
|
41 |
+
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
with st.spinner(t.get('processing', "Analizando texto...")):
|
43 |
+
# 1. Procesar el texto
|
44 |
+
doc = nlp_models[lang_code](text_input)
|
45 |
+
metrics = analyze_text_dimensions(doc)
|
46 |
+
|
47 |
+
# 2. Mostrar visualizaciones en la columna derecha
|
48 |
+
with visual_col:
|
49 |
+
from .current_situation_analysis import display_current_situation_visual
|
50 |
+
display_current_situation_visual(doc, metrics)
|
51 |
+
|
52 |
+
# 3. Obtener retroalimentaci贸n de Claude
|
53 |
+
feedback = get_claude_feedback(metrics, text_input)
|
54 |
+
|
55 |
+
# 4. Guardar los resultados
|
56 |
+
from ..database.current_situation_mongo_db import store_current_situation_result
|
57 |
+
|
58 |
+
if store_current_situation_result(
|
59 |
+
st.session_state.username,
|
60 |
+
text_input,
|
61 |
+
metrics,
|
62 |
+
feedback
|
63 |
+
):
|
64 |
+
st.success(t.get('save_success', "An谩lisis guardado exitosamente"))
|
65 |
|
66 |
+
# 5. Mostrar recomendaciones
|
67 |
+
show_recommendations(feedback, t)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
+
except Exception as e:
|
70 |
+
logger.error(f"Error en an谩lisis de situaci贸n actual: {str(e)}")
|
71 |
+
st.error(t.get('analysis_error', "Error al procesar el an谩lisis"))
|
72 |
+
|
73 |
+
|
74 |
|
75 |
def show_recommendations(feedback, t):
|
76 |
"""
|