Update modules/ui.py
Browse files- modules/ui.py +5 -30
modules/ui.py
CHANGED
|
@@ -10,8 +10,7 @@ from datetime import datetime
|
|
| 10 |
import base64
|
| 11 |
from spacy import displacy
|
| 12 |
import re
|
| 13 |
-
from .morpho_analysis import POS_TRANSLATIONS # Asegúrate de que esta importación esté presente
|
| 14 |
-
from .morpho_analysis import POS_COLORS # Asegúrate de que esta importación esté presente
|
| 15 |
|
| 16 |
# Importaciones locales
|
| 17 |
from .auth import authenticate_user, register_user, get_user_role
|
|
@@ -79,7 +78,7 @@ def display_chat_interface():
|
|
| 79 |
|
| 80 |
##########################################################################
|
| 81 |
|
| 82 |
-
def display_student_progress(username):
|
| 83 |
student_data = get_student_data(username)
|
| 84 |
|
| 85 |
if student_data is None:
|
|
@@ -101,7 +100,7 @@ def display_student_progress(username):
|
|
| 101 |
st.subheader("Conteo Total de Palabras por Categoría Gramatical")
|
| 102 |
|
| 103 |
df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
|
| 104 |
-
df['label'] = df.apply(lambda x: f"{x['category']}\n({x['count']})", axis=1)
|
| 105 |
|
| 106 |
fig, ax = plt.subplots(figsize=(12, 8), dpi=80)
|
| 107 |
colors = [POS_COLORS.get(cat, '#CCCCCC') for cat in df['category']]
|
|
@@ -112,32 +111,8 @@ def display_student_progress(username):
|
|
| 112 |
else:
|
| 113 |
st.info("No hay datos de conteo de palabras disponibles.")
|
| 114 |
|
| 115 |
-
#
|
| 116 |
-
|
| 117 |
-
with st.expander("Ver todos los Diagramas de Arco"):
|
| 118 |
-
for i, entry in enumerate(student_data['entries']):
|
| 119 |
-
if 'arc_diagrams' in entry and entry['arc_diagrams']:
|
| 120 |
-
st.subheader(f"Entrada {i+1} - {entry['timestamp']}")
|
| 121 |
-
st.write(entry['arc_diagrams'][0], unsafe_allow_html=True)
|
| 122 |
-
|
| 123 |
-
# Diagramas de Red (consolidados)
|
| 124 |
-
st.header("Diagramas de Red")
|
| 125 |
-
with st.expander("Ver todos los Diagramas de Red"):
|
| 126 |
-
for i, entry in enumerate(student_data['entries']):
|
| 127 |
-
if 'network_diagram' in entry and entry['network_diagram']:
|
| 128 |
-
st.subheader(f"Entrada {i+1} - {entry['timestamp']}")
|
| 129 |
-
try:
|
| 130 |
-
# Decodificar la imagen base64
|
| 131 |
-
image_bytes = base64.b64decode(entry['network_diagram'])
|
| 132 |
-
st.image(image_bytes)
|
| 133 |
-
except Exception as e:
|
| 134 |
-
st.error(f"Error al mostrar el diagrama de red: {str(e)}")
|
| 135 |
-
|
| 136 |
-
# Mostrar entradas recientes
|
| 137 |
-
#st.header("Entradas Recientes")
|
| 138 |
-
#for i, entry in enumerate(student_data['entries'][:5]): # Mostrar las 5 entradas más recientes
|
| 139 |
-
# with st.expander(f"Entrada {i+1} - {entry['timestamp']}"):
|
| 140 |
-
# st.write(entry['text'])
|
| 141 |
else:
|
| 142 |
st.warning("No se encontraron entradas para este estudiante.")
|
| 143 |
st.info("Intenta realizar algunos análisis de texto primero.")
|
|
|
|
| 10 |
import base64
|
| 11 |
from spacy import displacy
|
| 12 |
import re
|
| 13 |
+
from .morpho_analysis import POR_COLORS, POS_TRANSLATIONS # Asegúrate de que esta importación esté presente
|
|
|
|
| 14 |
|
| 15 |
# Importaciones locales
|
| 16 |
from .auth import authenticate_user, register_user, get_user_role
|
|
|
|
| 78 |
|
| 79 |
##########################################################################
|
| 80 |
|
| 81 |
+
def display_student_progress(username, lang_code='es'): # Añade el parámetro lang_code
|
| 82 |
student_data = get_student_data(username)
|
| 83 |
|
| 84 |
if student_data is None:
|
|
|
|
| 100 |
st.subheader("Conteo Total de Palabras por Categoría Gramatical")
|
| 101 |
|
| 102 |
df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
|
| 103 |
+
df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}\n({x['count']})", axis=1)
|
| 104 |
|
| 105 |
fig, ax = plt.subplots(figsize=(12, 8), dpi=80)
|
| 106 |
colors = [POS_COLORS.get(cat, '#CCCCCC') for cat in df['category']]
|
|
|
|
| 111 |
else:
|
| 112 |
st.info("No hay datos de conteo de palabras disponibles.")
|
| 113 |
|
| 114 |
+
# ... (resto del código para diagramas de arco, diagramas de red y entradas recientes)
|
| 115 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
else:
|
| 117 |
st.warning("No se encontraron entradas para este estudiante.")
|
| 118 |
st.info("Intenta realizar algunos análisis de texto primero.")
|