Spaces:
Sleeping
Sleeping
Update modules/studentact/current_situation_interface.py
Browse files
modules/studentact/current_situation_interface.py
CHANGED
|
@@ -100,32 +100,124 @@ def display_current_situation_interface(lang_code, nlp_models, t):
|
|
| 100 |
logger.error(f"Error en interfaz: {str(e)}")
|
| 101 |
st.error("Error general en la interfaz")
|
| 102 |
|
|
|
|
| 103 |
def display_current_situation_visual(doc, metrics):
|
| 104 |
-
"""Visualización de resultados"""
|
| 105 |
try:
|
| 106 |
with st.container():
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
except Exception as e:
|
| 126 |
-
logger.error(f"Error
|
| 127 |
-
st.error("Error al generar visualizaciones")
|
| 128 |
|
|
|
|
| 129 |
def show_recommendations(feedback, t):
|
| 130 |
"""
|
| 131 |
Muestra las recomendaciones y ejercicios personalizados para el estudiante,
|
|
|
|
| 100 |
logger.error(f"Error en interfaz: {str(e)}")
|
| 101 |
st.error("Error general en la interfaz")
|
| 102 |
|
| 103 |
+
################################################################
|
| 104 |
def display_current_situation_visual(doc, metrics):
|
| 105 |
+
"""Visualización mejorada de resultados con interpretaciones"""
|
| 106 |
try:
|
| 107 |
with st.container():
|
| 108 |
+
# Estilos CSS mejorados para los contenedores
|
| 109 |
+
st.markdown("""
|
| 110 |
+
<style>
|
| 111 |
+
.graph-container {
|
| 112 |
+
background-color: white;
|
| 113 |
+
border-radius: 10px;
|
| 114 |
+
padding: 20px;
|
| 115 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 116 |
+
margin: 15px 0;
|
| 117 |
+
}
|
| 118 |
+
.interpretation-box {
|
| 119 |
+
background-color: #f8f9fa;
|
| 120 |
+
border-left: 4px solid #0d6efd;
|
| 121 |
+
padding: 15px;
|
| 122 |
+
margin: 10px 0;
|
| 123 |
+
}
|
| 124 |
+
.metric-indicator {
|
| 125 |
+
font-size: 1.2em;
|
| 126 |
+
font-weight: 500;
|
| 127 |
+
color: #1f2937;
|
| 128 |
+
}
|
| 129 |
+
</style>
|
| 130 |
+
""", unsafe_allow_html=True)
|
| 131 |
+
|
| 132 |
+
# 1. Riqueza de Vocabulario
|
| 133 |
+
with st.expander("📚 Riqueza de Vocabulario", expanded=True):
|
| 134 |
+
st.markdown('<div class="graph-container">', unsafe_allow_html=True)
|
| 135 |
+
vocabulary_graph = create_vocabulary_network(doc)
|
| 136 |
+
if vocabulary_graph:
|
| 137 |
+
# Mostrar gráfico
|
| 138 |
+
st.pyplot(vocabulary_graph)
|
| 139 |
+
plt.close(vocabulary_graph)
|
| 140 |
+
|
| 141 |
+
# Interpretación
|
| 142 |
+
st.markdown('<div class="interpretation-box">', unsafe_allow_html=True)
|
| 143 |
+
st.markdown("**¿Qué significa este gráfico?**")
|
| 144 |
+
st.markdown("""
|
| 145 |
+
- 🔵 Los nodos azules representan palabras clave en tu texto
|
| 146 |
+
- 📏 El tamaño de cada nodo indica su frecuencia de uso
|
| 147 |
+
- 🔗 Las líneas conectan palabras que aparecen juntas frecuentemente
|
| 148 |
+
- 🎨 Los colores más intensos indican palabras más centrales
|
| 149 |
+
""")
|
| 150 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 151 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 152 |
+
|
| 153 |
+
# 2. Estructura de Oraciones
|
| 154 |
+
with st.expander("🏗️ Complejidad Estructural", expanded=True):
|
| 155 |
+
st.markdown('<div class="graph-container">', unsafe_allow_html=True)
|
| 156 |
+
syntax_graph = create_syntax_complexity_graph(doc)
|
| 157 |
+
if syntax_graph:
|
| 158 |
+
st.pyplot(syntax_graph)
|
| 159 |
+
plt.close(syntax_graph)
|
| 160 |
+
|
| 161 |
+
st.markdown('<div class="interpretation-box">', unsafe_allow_html=True)
|
| 162 |
+
st.markdown("**Análisis de la estructura:**")
|
| 163 |
+
st.markdown("""
|
| 164 |
+
- 📊 Las barras muestran la complejidad de cada oración
|
| 165 |
+
- 📈 Mayor altura indica estructuras más elaboradas
|
| 166 |
+
- 🎯 La línea punteada indica el nivel óptimo de complejidad
|
| 167 |
+
- 🔄 Variación en las alturas sugiere dinamismo en la escritura
|
| 168 |
+
""")
|
| 169 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 170 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 171 |
+
|
| 172 |
+
# 3. Cohesión Textual
|
| 173 |
+
with st.expander("🔄 Cohesión del Texto", expanded=True):
|
| 174 |
+
st.markdown('<div class="graph-container">', unsafe_allow_html=True)
|
| 175 |
+
cohesion_map = create_cohesion_heatmap(doc)
|
| 176 |
+
if cohesion_map:
|
| 177 |
+
st.pyplot(cohesion_map)
|
| 178 |
+
plt.close(cohesion_map)
|
| 179 |
+
|
| 180 |
+
st.markdown('<div class="interpretation-box">', unsafe_allow_html=True)
|
| 181 |
+
st.markdown("**¿Cómo leer el mapa de calor?**")
|
| 182 |
+
st.markdown("""
|
| 183 |
+
- 🌈 Colores más intensos indican mayor conexión entre oraciones
|
| 184 |
+
- 📝 La diagonal muestra la coherencia interna de cada oración
|
| 185 |
+
- 🔗 Las zonas claras sugieren oportunidades de mejorar conexiones
|
| 186 |
+
- 🎯 Un buen texto muestra patrones de color consistentes
|
| 187 |
+
""")
|
| 188 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 189 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 190 |
+
|
| 191 |
+
# 4. Métricas Generales
|
| 192 |
+
with st.expander("📊 Resumen de Métricas", expanded=True):
|
| 193 |
+
col1, col2, col3 = st.columns(3)
|
| 194 |
|
| 195 |
+
with col1:
|
| 196 |
+
st.metric(
|
| 197 |
+
"Diversidad Léxica",
|
| 198 |
+
f"{metrics['vocabulary_richness']:.2f}/1.0",
|
| 199 |
+
help="Mide la variedad de palabras diferentes utilizadas"
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
with col2:
|
| 203 |
+
st.metric(
|
| 204 |
+
"Complejidad Estructural",
|
| 205 |
+
f"{metrics['structural_complexity']:.2f}/1.0",
|
| 206 |
+
help="Indica qué tan elaboradas son las estructuras de las oraciones"
|
| 207 |
+
)
|
| 208 |
+
|
| 209 |
+
with col3:
|
| 210 |
+
st.metric(
|
| 211 |
+
"Cohesión Textual",
|
| 212 |
+
f"{metrics['cohesion_score']:.2f}/1.0",
|
| 213 |
+
help="Evalúa qué tan bien conectadas están las ideas entre sí"
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
except Exception as e:
|
| 217 |
+
logger.error(f"Error en visualización: {str(e)}")
|
| 218 |
+
st.error("Error al generar las visualizaciones")
|
| 219 |
|
| 220 |
+
################################################################
|
| 221 |
def show_recommendations(feedback, t):
|
| 222 |
"""
|
| 223 |
Muestra las recomendaciones y ejercicios personalizados para el estudiante,
|