Spaces:
Sleeping
Sleeping
Update modules/studentact/current_situation_interface.py
Browse files
modules/studentact/current_situation_interface.py
CHANGED
|
@@ -111,11 +111,11 @@ def display_current_situation_interface(lang_code, nlp_models, t):
|
|
| 111 |
|
| 112 |
def display_results(metrics):
|
| 113 |
"""
|
| 114 |
-
Muestra los resultados del análisis: métricas y gráfico radar.
|
| 115 |
"""
|
| 116 |
try:
|
| 117 |
-
#
|
| 118 |
-
|
| 119 |
|
| 120 |
metrics_config = [
|
| 121 |
("Vocabulario", metrics['vocabulary']['normalized_score'], "Riqueza y variedad del vocabulario"),
|
|
@@ -124,21 +124,33 @@ def display_results(metrics):
|
|
| 124 |
("Claridad", metrics['clarity']['normalized_score'], "Facilidad de comprensión del texto")
|
| 125 |
]
|
| 126 |
|
| 127 |
-
# Mostrar métricas
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
with graph_col:
|
| 143 |
# Preparar datos para el gráfico
|
| 144 |
categories = [m[0] for m in metrics_config]
|
|
@@ -146,7 +158,7 @@ def display_results(metrics):
|
|
| 146 |
values_pattern = [1.0] * len(categories)
|
| 147 |
|
| 148 |
# Crear y configurar gráfico
|
| 149 |
-
fig = plt.figure(figsize=(
|
| 150 |
ax = fig.add_subplot(111, projection='polar')
|
| 151 |
|
| 152 |
# Configurar gráfico radar
|
|
@@ -157,18 +169,28 @@ def display_results(metrics):
|
|
| 157 |
|
| 158 |
# Configurar ejes
|
| 159 |
ax.set_xticks(angles[:-1])
|
| 160 |
-
ax.set_xticklabels(categories, fontsize=
|
| 161 |
circle_ticks = np.arange(0, 1.1, 0.2)
|
| 162 |
ax.set_yticks(circle_ticks)
|
| 163 |
ax.set_yticklabels([f'{tick:.1f}' for tick in circle_ticks], fontsize=8)
|
| 164 |
ax.set_ylim(0, 1)
|
| 165 |
|
| 166 |
-
# Dibujar gráfico
|
| 167 |
-
ax.plot(angles, values_pattern, '
|
| 168 |
-
ax.fill(angles, values_pattern, '
|
| 169 |
-
ax.plot(angles, values_user, '
|
| 170 |
-
ax.fill(angles, values_user, '
|
| 171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
plt.tight_layout()
|
| 174 |
st.pyplot(fig)
|
|
|
|
| 111 |
|
| 112 |
def display_results(metrics):
|
| 113 |
"""
|
| 114 |
+
Muestra los resultados del análisis: métricas verticalmente y gráfico radar.
|
| 115 |
"""
|
| 116 |
try:
|
| 117 |
+
# Crear dos columnas para métricas y gráfico
|
| 118 |
+
metrics_col, graph_col = st.columns([1, 1.5])
|
| 119 |
|
| 120 |
metrics_config = [
|
| 121 |
("Vocabulario", metrics['vocabulary']['normalized_score'], "Riqueza y variedad del vocabulario"),
|
|
|
|
| 124 |
("Claridad", metrics['clarity']['normalized_score'], "Facilidad de comprensión del texto")
|
| 125 |
]
|
| 126 |
|
| 127 |
+
# Mostrar métricas verticalmente
|
| 128 |
+
with metrics_col:
|
| 129 |
+
# Contenedor con bordes para las métricas
|
| 130 |
+
st.markdown("""
|
| 131 |
+
<style>
|
| 132 |
+
.metric-container {
|
| 133 |
+
background-color: #ffffff;
|
| 134 |
+
padding: 1rem;
|
| 135 |
+
border-radius: 0.5rem;
|
| 136 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
| 137 |
+
margin-bottom: 0.5rem;
|
| 138 |
+
}
|
| 139 |
+
</style>
|
| 140 |
+
""", unsafe_allow_html=True)
|
| 141 |
+
|
| 142 |
+
for label, value, help_text in metrics_config:
|
| 143 |
+
with st.container():
|
| 144 |
+
st.metric(
|
| 145 |
+
label,
|
| 146 |
+
f"{value:.2f}",
|
| 147 |
+
"Meta: 1.00",
|
| 148 |
+
delta_color="off",
|
| 149 |
+
help=help_text
|
| 150 |
+
)
|
| 151 |
+
st.markdown("<div style='margin-bottom: 1rem;'></div>", unsafe_allow_html=True)
|
| 152 |
+
|
| 153 |
+
# Gráfico radar en la columna derecha
|
| 154 |
with graph_col:
|
| 155 |
# Preparar datos para el gráfico
|
| 156 |
categories = [m[0] for m in metrics_config]
|
|
|
|
| 158 |
values_pattern = [1.0] * len(categories)
|
| 159 |
|
| 160 |
# Crear y configurar gráfico
|
| 161 |
+
fig = plt.figure(figsize=(8, 8)) # Aumentado el tamaño
|
| 162 |
ax = fig.add_subplot(111, projection='polar')
|
| 163 |
|
| 164 |
# Configurar gráfico radar
|
|
|
|
| 169 |
|
| 170 |
# Configurar ejes
|
| 171 |
ax.set_xticks(angles[:-1])
|
| 172 |
+
ax.set_xticklabels(categories, fontsize=10) # Aumentado el tamaño de fuente
|
| 173 |
circle_ticks = np.arange(0, 1.1, 0.2)
|
| 174 |
ax.set_yticks(circle_ticks)
|
| 175 |
ax.set_yticklabels([f'{tick:.1f}' for tick in circle_ticks], fontsize=8)
|
| 176 |
ax.set_ylim(0, 1)
|
| 177 |
|
| 178 |
+
# Dibujar gráfico con colores mejorados
|
| 179 |
+
ax.plot(angles, values_pattern, '#2ecc71', linestyle='--', linewidth=1, label='Patrón', alpha=0.5)
|
| 180 |
+
ax.fill(angles, values_pattern, '#2ecc71', alpha=0.1)
|
| 181 |
+
ax.plot(angles, values_user, '#3498db', linewidth=2, label='Tu escritura')
|
| 182 |
+
ax.fill(angles, values_user, '#3498db', alpha=0.2)
|
| 183 |
+
|
| 184 |
+
# Ajustar leyenda
|
| 185 |
+
ax.legend(
|
| 186 |
+
loc='upper right',
|
| 187 |
+
bbox_to_anchor=(0.1, 0.1),
|
| 188 |
+
fontsize=10,
|
| 189 |
+
frameon=True,
|
| 190 |
+
facecolor='white',
|
| 191 |
+
edgecolor='none',
|
| 192 |
+
shadow=True
|
| 193 |
+
)
|
| 194 |
|
| 195 |
plt.tight_layout()
|
| 196 |
st.pyplot(fig)
|