Update modules/studentact/student_activities_v2.py
Browse files
modules/studentact/student_activities_v2.py
CHANGED
|
@@ -466,7 +466,9 @@ def display_morphosyntax_activities(username: str, t: dict):
|
|
| 466 |
logger.error(f"Error mostrando análisis morfosintáctico: {str(e)}")
|
| 467 |
st.error(t.get('error_morpho', 'Error al mostrar análisis morfosintáctico'))
|
| 468 |
|
| 469 |
-
|
|
|
|
|
|
|
| 470 |
def display_semantic_activities(username: str, t: dict):
|
| 471 |
"""Muestra actividades de análisis semántico"""
|
| 472 |
try:
|
|
@@ -531,7 +533,8 @@ def display_semantic_activities(username: str, t: dict):
|
|
| 531 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
| 532 |
st.error(t.get('error_semantic', 'Error al mostrar análisis semántico'))
|
| 533 |
|
| 534 |
-
|
|
|
|
| 535 |
###############################################################################################
|
| 536 |
def display_discourse_activities(username: str, t: dict):
|
| 537 |
"""Muestra actividades de análisis del discurso (mostrado como 'Análisis comparado de textos' en la UI)"""
|
|
@@ -558,71 +561,106 @@ def display_discourse_activities(username: str, t: dict):
|
|
| 558 |
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 559 |
|
| 560 |
with st.expander(f"{t.get('analysis_date', 'Fecha')}: {formatted_date}", expanded=False):
|
| 561 |
-
#
|
| 562 |
-
|
| 563 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 564 |
|
| 565 |
-
#
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 572 |
|
| 573 |
-
#
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
logger.error(f"Error mostrando graph1: {str(e)}")
|
| 599 |
-
|
| 600 |
-
# Mostrar graph2 (Documento 2)
|
| 601 |
-
if 'graph2' in analysis:
|
| 602 |
-
try:
|
| 603 |
-
# Verificar que sea bytes
|
| 604 |
-
if isinstance(analysis['graph2'], bytes):
|
| 605 |
-
st.image(analysis['graph2'],
|
| 606 |
-
caption="Documento 2",
|
| 607 |
-
use_container_width=True) # Usar use_container_width en lugar de use_column_width
|
| 608 |
-
has_graphs = True
|
| 609 |
-
else:
|
| 610 |
-
logger.warning(f"graph2 no es bytes: {type(analysis['graph2'])}")
|
| 611 |
-
except Exception as e:
|
| 612 |
-
logger.error(f"Error mostrando graph2: {str(e)}")
|
| 613 |
-
|
| 614 |
-
if not has_graphs:
|
| 615 |
-
st.info(t.get('no_visualization', 'No hay visualización disponible'))
|
| 616 |
-
|
| 617 |
-
# Añadir leyenda de interpretación
|
| 618 |
-
st.markdown("### 📊 " + t.get('graph_interpretation', 'Interpretación del grafo:'))
|
| 619 |
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 626 |
|
| 627 |
except Exception as e:
|
| 628 |
logger.error(f"Error procesando análisis individual: {str(e)}")
|
|
@@ -633,6 +671,10 @@ def display_discourse_activities(username: str, t: dict):
|
|
| 633 |
# Usamos el término "análisis comparado de textos" en la UI
|
| 634 |
st.error(t.get('error_discourse', 'Error al mostrar análisis comparado de textos'))
|
| 635 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 636 |
#################################################################################
|
| 637 |
|
| 638 |
def display_discourse_comparison(analysis: dict, t: dict):
|
|
|
|
| 466 |
logger.error(f"Error mostrando análisis morfosintáctico: {str(e)}")
|
| 467 |
st.error(t.get('error_morpho', 'Error al mostrar análisis morfosintáctico'))
|
| 468 |
|
| 469 |
+
##############################################################################################
|
| 470 |
+
##############################################################################################
|
| 471 |
+
##############################################################################################
|
| 472 |
def display_semantic_activities(username: str, t: dict):
|
| 473 |
"""Muestra actividades de análisis semántico"""
|
| 474 |
try:
|
|
|
|
| 533 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
| 534 |
st.error(t.get('error_semantic', 'Error al mostrar análisis semántico'))
|
| 535 |
|
| 536 |
+
###############################################################################################
|
| 537 |
+
###############################################################################################
|
| 538 |
###############################################################################################
|
| 539 |
def display_discourse_activities(username: str, t: dict):
|
| 540 |
"""Muestra actividades de análisis del discurso (mostrado como 'Análisis comparado de textos' en la UI)"""
|
|
|
|
| 561 |
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 562 |
|
| 563 |
with st.expander(f"{t.get('analysis_date', 'Fecha')}: {formatted_date}", expanded=False):
|
| 564 |
+
# Crear dos columnas para mostrar los documentos lado a lado
|
| 565 |
+
col1, col2 = st.columns(2)
|
| 566 |
+
|
| 567 |
+
# Documento 1 - Columna izquierda
|
| 568 |
+
with col1:
|
| 569 |
+
st.subheader(t.get('doc1_title', 'Documento 1'))
|
| 570 |
+
st.markdown(t.get('key_concepts', 'Conceptos Clave'))
|
| 571 |
|
| 572 |
+
# Mostrar conceptos clave en formato de etiquetas
|
| 573 |
+
if 'key_concepts1' in analysis and analysis['key_concepts1']:
|
| 574 |
+
concepts_html = f"""
|
| 575 |
+
<div style="display: flex; flex-wrap: nowrap; gap: 8px; padding: 12px;
|
| 576 |
+
background-color: #f8f9fa; border-radius: 8px; overflow-x: auto;
|
| 577 |
+
margin-bottom: 15px; white-space: nowrap;">
|
| 578 |
+
{''.join([
|
| 579 |
+
f'<div style="background-color: white; border-radius: 4px; padding: 6px 10px; display: inline-flex; align-items: center; gap: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); flex-shrink: 0;">'
|
| 580 |
+
f'<span style="font-weight: 500; color: #1f2937; font-size: 0.85em;">{concept}</span>'
|
| 581 |
+
f'<span style="color: #6b7280; font-size: 0.75em;">({freq:.2f})</span></div>'
|
| 582 |
+
for concept, freq in analysis['key_concepts1']
|
| 583 |
+
])}
|
| 584 |
+
</div>
|
| 585 |
+
"""
|
| 586 |
+
st.markdown(concepts_html, unsafe_allow_html=True)
|
| 587 |
+
else:
|
| 588 |
+
st.info(t.get('no_concepts', 'No hay conceptos disponibles'))
|
| 589 |
|
| 590 |
+
# Mostrar grafo 1
|
| 591 |
+
if 'graph1' in analysis:
|
| 592 |
+
try:
|
| 593 |
+
if isinstance(analysis['graph1'], bytes):
|
| 594 |
+
st.image(
|
| 595 |
+
analysis['graph1'],
|
| 596 |
+
use_container_width=True
|
| 597 |
+
)
|
| 598 |
+
else:
|
| 599 |
+
logger.warning(f"graph1 no es bytes: {type(analysis['graph1'])}")
|
| 600 |
+
st.warning(t.get('graph_not_available', 'Gráfico no disponible'))
|
| 601 |
+
except Exception as e:
|
| 602 |
+
logger.error(f"Error mostrando graph1: {str(e)}")
|
| 603 |
+
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
| 604 |
+
else:
|
| 605 |
+
st.info(t.get('no_visualization', 'No hay visualización disponible'))
|
| 606 |
+
|
| 607 |
+
# Interpretación del grafo
|
| 608 |
+
st.markdown("**📊 Interpretación del grafo:**")
|
| 609 |
+
st.markdown("""
|
| 610 |
+
- 🔀 Las flechas indican la dirección de la relación entre conceptos
|
| 611 |
+
- 🎨 Los colores más intensos indican conceptos más centrales en el texto
|
| 612 |
+
- ⭕ El tamaño de los nodos representa la frecuencia del concepto
|
| 613 |
+
- ↔️ El grosor de las líneas indica la fuerza de la conexión
|
| 614 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 615 |
|
| 616 |
+
# Documento 2 - Columna derecha
|
| 617 |
+
with col2:
|
| 618 |
+
st.subheader(t.get('doc2_title', 'Documento 2'))
|
| 619 |
+
st.markdown(t.get('key_concepts', 'Conceptos Clave'))
|
| 620 |
+
|
| 621 |
+
# Mostrar conceptos clave en formato de etiquetas
|
| 622 |
+
if 'key_concepts2' in analysis and analysis['key_concepts2']:
|
| 623 |
+
concepts_html = f"""
|
| 624 |
+
<div style="display: flex; flex-wrap: nowrap; gap: 8px; padding: 12px;
|
| 625 |
+
background-color: #f8f9fa; border-radius: 8px; overflow-x: auto;
|
| 626 |
+
margin-bottom: 15px; white-space: nowrap;">
|
| 627 |
+
{''.join([
|
| 628 |
+
f'<div style="background-color: white; border-radius: 4px; padding: 6px 10px; display: inline-flex; align-items: center; gap: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); flex-shrink: 0;">'
|
| 629 |
+
f'<span style="font-weight: 500; color: #1f2937; font-size: 0.85em;">{concept}</span>'
|
| 630 |
+
f'<span style="color: #6b7280; font-size: 0.75em;">({freq:.2f})</span></div>'
|
| 631 |
+
for concept, freq in analysis['key_concepts2']
|
| 632 |
+
])}
|
| 633 |
+
</div>
|
| 634 |
+
"""
|
| 635 |
+
st.markdown(concepts_html, unsafe_allow_html=True)
|
| 636 |
+
else:
|
| 637 |
+
st.info(t.get('no_concepts', 'No hay conceptos disponibles'))
|
| 638 |
+
|
| 639 |
+
# Mostrar grafo 2
|
| 640 |
+
if 'graph2' in analysis:
|
| 641 |
+
try:
|
| 642 |
+
if isinstance(analysis['graph2'], bytes):
|
| 643 |
+
st.image(
|
| 644 |
+
analysis['graph2'],
|
| 645 |
+
use_container_width=True
|
| 646 |
+
)
|
| 647 |
+
else:
|
| 648 |
+
logger.warning(f"graph2 no es bytes: {type(analysis['graph2'])}")
|
| 649 |
+
st.warning(t.get('graph_not_available', 'Gráfico no disponible'))
|
| 650 |
+
except Exception as e:
|
| 651 |
+
logger.error(f"Error mostrando graph2: {str(e)}")
|
| 652 |
+
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
| 653 |
+
else:
|
| 654 |
+
st.info(t.get('no_visualization', 'No hay visualización disponible'))
|
| 655 |
+
|
| 656 |
+
# Interpretación del grafo
|
| 657 |
+
st.markdown("**📊 Interpretación del grafo:**")
|
| 658 |
+
st.markdown("""
|
| 659 |
+
- 🔀 Las flechas indican la dirección de la relación entre conceptos
|
| 660 |
+
- 🎨 Los colores más intensos indican conceptos más centrales en el texto
|
| 661 |
+
- ⭕ El tamaño de los nodos representa la frecuencia del concepto
|
| 662 |
+
- ↔️ El grosor de las líneas indica la fuerza de la conexión
|
| 663 |
+
""")
|
| 664 |
|
| 665 |
except Exception as e:
|
| 666 |
logger.error(f"Error procesando análisis individual: {str(e)}")
|
|
|
|
| 671 |
# Usamos el término "análisis comparado de textos" en la UI
|
| 672 |
st.error(t.get('error_discourse', 'Error al mostrar análisis comparado de textos'))
|
| 673 |
|
| 674 |
+
|
| 675 |
+
|
| 676 |
+
|
| 677 |
+
|
| 678 |
#################################################################################
|
| 679 |
|
| 680 |
def display_discourse_comparison(analysis: dict, t: dict):
|