AIdeaText commited on
Commit
b07a697
·
verified ·
1 Parent(s): 1bb02aa

Update modules/studentact/current_situation_interface.py

Browse files
modules/studentact/current_situation_interface.py CHANGED
@@ -210,6 +210,8 @@ def display_current_situation_interface(lang_code, nlp_models, t):
210
  logger.error(f"Error en interfaz principal: {str(e)}")
211
  st.error(current_situation_t.get('error_interface', "Ocurrió un error al cargar la interfaz"))
212
 
 
 
213
  def display_diagnosis(metrics, text_type=None, lang_code='es', t=None):
214
  """
215
  Muestra los resultados del análisis: métricas verticalmente y gráfico radar.
@@ -287,7 +289,7 @@ def display_diagnosis(metrics, text_type=None, lang_code='es', t=None):
287
 
288
  # Gráfico radar en la columna derecha
289
  with graph_col:
290
- display_radar_chart(metrics_config, thresholds)
291
 
292
  except Exception as e:
293
  logger.error(f"Error mostrando resultados: {str(e)}")
@@ -295,19 +297,21 @@ def display_diagnosis(metrics, text_type=None, lang_code='es', t=None):
295
 
296
  ##################################################################
297
  ##################################################################
298
- def display_radar_chart(metrics_config, thresholds):
299
- legend_translations = {
300
- 'es': {'min': 'Mínimo', 'target': 'Meta', 'user': 'Tu escritura'},
301
- 'en': {'min': 'Minimum', 'target': 'Target', 'user': 'Your writing'},
302
- 'uk': {'min': 'Мінімум', 'target': 'Ціль', 'user': 'Ваш текст'}
303
- }
304
- translations = legend_translations.get(lang_code, legend_translations['es'])
305
-
306
  """
307
  Muestra el gráfico radar con los resultados.
308
  """
309
-
310
  try:
 
 
 
 
 
 
 
 
 
 
311
  # Preparar datos para el gráfico
312
  categories = [m['label'] for m in metrics_config]
313
  values_user = [m['value'] for m in metrics_config]
@@ -333,14 +337,14 @@ def display_radar_chart(metrics_config, thresholds):
333
  ax.set_yticklabels([f'{tick:.1f}' for tick in circle_ticks], fontsize=8)
334
  ax.set_ylim(0, 1)
335
 
336
- # Dibujar áreas de umbrales
337
- ax.plot(angles, min_values, '#e74c3c', linestyle='--', linewidth=1, label='Mínimo', alpha=0.5)
338
- ax.plot(angles, target_values, '#2ecc71', linestyle='--', linewidth=1, label='Meta', alpha=0.5)
339
  ax.fill_between(angles, target_values, [1]*len(angles), color='#2ecc71', alpha=0.1)
340
  ax.fill_between(angles, [0]*len(angles), min_values, color='#e74c3c', alpha=0.1)
341
 
342
- # Dibujar valores del usuario
343
- ax.plot(angles, values_user, '#3498db', linewidth=2, label='Tu escritura')
344
  ax.fill(angles, values_user, '#3498db', alpha=0.2)
345
 
346
  # Ajustar leyenda
 
210
  logger.error(f"Error en interfaz principal: {str(e)}")
211
  st.error(current_situation_t.get('error_interface', "Ocurrió un error al cargar la interfaz"))
212
 
213
+ #################################################################
214
+ #################################################################
215
  def display_diagnosis(metrics, text_type=None, lang_code='es', t=None):
216
  """
217
  Muestra los resultados del análisis: métricas verticalmente y gráfico radar.
 
289
 
290
  # Gráfico radar en la columna derecha
291
  with graph_col:
292
+ display_radar_chart(metrics_config, thresholds, lang_code) # Pasar el parámetro lang_code
293
 
294
  except Exception as e:
295
  logger.error(f"Error mostrando resultados: {str(e)}")
 
297
 
298
  ##################################################################
299
  ##################################################################
300
+ def display_radar_chart(metrics_config, thresholds, lang_code='es'):
 
 
 
 
 
 
 
301
  """
302
  Muestra el gráfico radar con los resultados.
303
  """
 
304
  try:
305
+ # Traducción de las etiquetas de leyenda según el idioma
306
+ legend_translations = {
307
+ 'es': {'min': 'Mínimo', 'target': 'Meta', 'user': 'Tu escritura'},
308
+ 'en': {'min': 'Minimum', 'target': 'Target', 'user': 'Your writing'},
309
+ 'uk': {'min': 'Мінімум', 'target': 'Ціль', 'user': 'Ваш текст'}
310
+ }
311
+
312
+ # Usar español por defecto si el idioma no está soportado
313
+ translations = legend_translations.get(lang_code, legend_translations['es'])
314
+
315
  # Preparar datos para el gráfico
316
  categories = [m['label'] for m in metrics_config]
317
  values_user = [m['value'] for m in metrics_config]
 
337
  ax.set_yticklabels([f'{tick:.1f}' for tick in circle_ticks], fontsize=8)
338
  ax.set_ylim(0, 1)
339
 
340
+ # Dibujar áreas de umbrales con etiquetas traducidas
341
+ ax.plot(angles, min_values, '#e74c3c', linestyle='--', linewidth=1, label=translations['min'], alpha=0.5)
342
+ ax.plot(angles, target_values, '#2ecc71', linestyle='--', linewidth=1, label=translations['target'], alpha=0.5)
343
  ax.fill_between(angles, target_values, [1]*len(angles), color='#2ecc71', alpha=0.1)
344
  ax.fill_between(angles, [0]*len(angles), min_values, color='#e74c3c', alpha=0.1)
345
 
346
+ # Dibujar valores del usuario con etiqueta traducida
347
+ ax.plot(angles, values_user, '#3498db', linewidth=2, label=translations['user'])
348
  ax.fill(angles, values_user, '#3498db', alpha=0.2)
349
 
350
  # Ajustar leyenda