AIdeaText commited on
Commit
9d00d66
·
verified ·
1 Parent(s): 4328361

Update modules/studentact/current_situation_interface.py

Browse files
modules/studentact/current_situation_interface.py CHANGED
@@ -158,6 +158,7 @@ def display_current_situation_interface(lang_code, nlp_models, t):
158
 
159
  ###################################3333
160
 
 
161
  def display_results(metrics, text_type=None):
162
  """
163
  Muestra los resultados del análisis: métricas verticalmente y gráfico radar.
@@ -234,7 +235,91 @@ def display_results(metrics, text_type=None):
234
  except Exception as e:
235
  logger.error(f"Error mostrando resultados: {str(e)}")
236
  st.error("Error al mostrar los resultados")
 
237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
 
239
  ######################################
240
  def display_radar_chart(metrics_config, thresholds):
 
158
 
159
  ###################################3333
160
 
161
+ '''
162
  def display_results(metrics, text_type=None):
163
  """
164
  Muestra los resultados del análisis: métricas verticalmente y gráfico radar.
 
235
  except Exception as e:
236
  logger.error(f"Error mostrando resultados: {str(e)}")
237
  st.error("Error al mostrar los resultados")
238
+ '''
239
 
240
+ def display_results(metrics, text_type=None, t=None):
241
+ """
242
+ Muestra los resultados del análisis: métricas verticalmente y gráfico radar,
243
+ junto con recomendaciones personalizadas en el idioma seleccionado.
244
+ """
245
+ try:
246
+ # Usar valor por defecto si no se especifica tipo
247
+ text_type = text_type or 'student_essay'
248
+
249
+ # Obtener el código de idioma actual
250
+ lang_code = st.session_state.lang_code
251
+
252
+ # Obtener traducciones si no se proporcionaron
253
+ if t is None:
254
+ t = get_translations(lang_code)
255
+
256
+ # Obtener umbrales según el tipo de texto
257
+ thresholds = TEXT_TYPES[text_type]['thresholds']
258
+
259
+ # Crear dos columnas para las métricas y el gráfico
260
+ metrics_col, graph_col = st.columns([1, 1.5])
261
+
262
+ # Columna de métricas
263
+ with metrics_col:
264
+ metrics_config = [
265
+ {
266
+ 'label': t.get('SITUATION_ANALYSIS', {}).get('vocabulary', "Vocabulario"),
267
+ 'key': 'vocabulary',
268
+ 'value': metrics['vocabulary']['normalized_score'],
269
+ 'help': t.get('SITUATION_ANALYSIS', {}).get('vocabulary_help', "Riqueza y variedad del vocabulario"),
270
+ 'thresholds': thresholds['vocabulary']
271
+ },
272
+ {
273
+ 'label': t.get('SITUATION_ANALYSIS', {}).get('structure', "Estructura"),
274
+ 'key': 'structure',
275
+ 'value': metrics['structure']['normalized_score'],
276
+ 'help': t.get('SITUATION_ANALYSIS', {}).get('structure_help', "Organización y complejidad de oraciones"),
277
+ 'thresholds': thresholds['structure']
278
+ },
279
+ {
280
+ 'label': t.get('SITUATION_ANALYSIS', {}).get('cohesion', "Cohesión"),
281
+ 'key': 'cohesion',
282
+ 'value': metrics['cohesion']['normalized_score'],
283
+ 'help': t.get('SITUATION_ANALYSIS', {}).get('cohesion_help', "Conexión entre ideas y párrafos"),
284
+ 'thresholds': thresholds['cohesion']
285
+ },
286
+ {
287
+ 'label': t.get('SITUATION_ANALYSIS', {}).get('clarity', "Claridad"),
288
+ 'key': 'clarity',
289
+ 'value': metrics['clarity']['normalized_score'],
290
+ 'help': t.get('SITUATION_ANALYSIS', {}).get('clarity_help', "Facilidad de comprensión"),
291
+ 'thresholds': thresholds['clarity']
292
+ }
293
+ ]
294
+
295
+ # Mostrar las métricas como barras verticales
296
+ for metric in metrics_config:
297
+ st.metric(
298
+ label=f"{metric['label']} - {int(metric['value']*100)}%",
299
+ value="",
300
+ help=metric['help']
301
+ )
302
+ st.progress(metric['value'])
303
+ st.markdown("---")
304
+
305
+ # Columna del gráfico radar
306
+ with graph_col:
307
+ # Generar y mostrar el gráfico radar
308
+ fig = create_radar_chart(metrics, t)
309
+ st.pyplot(fig)
310
+
311
+ # Generar recomendaciones basadas en métricas y tipo de texto
312
+ recommendations = generate_recommendations(metrics, text_type, lang_code, t)
313
+
314
+ # Mostrar sección de recomendaciones
315
+ st.subheader(t.get('SITUATION_ANALYSIS', {}).get('recommendations_title', "Recomendaciones para mejorar"))
316
+
317
+ # Mostrar recomendaciones en tarjetas con estilo
318
+ display_recommendations(recommendations, t)
319
+
320
+ except Exception as e:
321
+ logger.error(f"Error displaying results: {str(e)}")
322
+ st.error(t.get('SITUATION_ANALYSIS', {}).get('display_error', "Error al mostrar los resultados del análisis"))
323
 
324
  ######################################
325
  def display_radar_chart(metrics_config, thresholds):