Update modules/ui.py
Browse files- modules/ui.py +15 -3
modules/ui.py
CHANGED
|
@@ -11,6 +11,8 @@ import base64
|
|
| 11 |
from spacy import displacy
|
| 12 |
import re
|
| 13 |
from .morpho_analysis import POS_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
|
|
@@ -157,6 +159,7 @@ def display_chat_interface():
|
|
| 157 |
##########################################################################
|
| 158 |
|
| 159 |
def display_student_progress(username, lang_code='es'): # Añade el parámetro lang_code
|
|
|
|
| 160 |
student_data = get_student_data(username)
|
| 161 |
|
| 162 |
if student_data is None:
|
|
@@ -172,19 +175,28 @@ def display_student_progress(username, lang_code='es'): # Añade el parámetro
|
|
| 172 |
# Mostrar estadísticas generales
|
| 173 |
st.header("Estadísticas Generales")
|
| 174 |
st.metric("Total de entradas", student_data['entries_count'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
# Treemap para el conteo de palabras por categoría
|
| 177 |
if student_data['word_count']:
|
| 178 |
-
st.subheader("
|
| 179 |
|
| 180 |
df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
|
| 181 |
df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}\n({x['count']})", axis=1)
|
| 182 |
|
| 183 |
fig, ax = plt.subplots(figsize=(12, 8), dpi=80)
|
| 184 |
colors = [POS_COLORS.get(cat, '#CCCCCC') for cat in df['category']]
|
| 185 |
-
squarify.plot(sizes=df['count'], label=df['label'], color=colors, alpha=0.8, ax=ax)
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
| 187 |
plt.axis('off')
|
|
|
|
| 188 |
st.pyplot(fig)
|
| 189 |
else:
|
| 190 |
st.info("No hay datos de conteo de palabras disponibles.")
|
|
|
|
| 11 |
from spacy import displacy
|
| 12 |
import re
|
| 13 |
from .morpho_analysis import POS_COLORS, POS_TRANSLATIONS # Asegúrate de que esta importación esté presente
|
| 14 |
+
print("POS_COLORS:", POS_COLORS)
|
| 15 |
+
print("POS_TRANSLATIONS:", POS_TRANSLATIONS)
|
| 16 |
|
| 17 |
# Importaciones locales
|
| 18 |
from .auth import authenticate_user, register_user, get_user_role
|
|
|
|
| 159 |
##########################################################################
|
| 160 |
|
| 161 |
def display_student_progress(username, lang_code='es'): # Añade el parámetro lang_code
|
| 162 |
+
print("lang_code:", lang_code)
|
| 163 |
student_data = get_student_data(username)
|
| 164 |
|
| 165 |
if student_data is None:
|
|
|
|
| 175 |
# Mostrar estadísticas generales
|
| 176 |
st.header("Estadísticas Generales")
|
| 177 |
st.metric("Total de entradas", student_data['entries_count'])
|
| 178 |
+
|
| 179 |
+
print("student_data['word_count']:", student_data['word_count'])
|
| 180 |
+
print("df:", df)
|
| 181 |
+
print("colors:", colors)
|
| 182 |
+
print("labels:", df['label'].tolist())
|
| 183 |
|
| 184 |
# Treemap para el conteo de palabras por categoría
|
| 185 |
if student_data['word_count']:
|
| 186 |
+
st.subheader("Total de palabras por categoria gramatical")
|
| 187 |
|
| 188 |
df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
|
| 189 |
df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}\n({x['count']})", axis=1)
|
| 190 |
|
| 191 |
fig, ax = plt.subplots(figsize=(12, 8), dpi=80)
|
| 192 |
colors = [POS_COLORS.get(cat, '#CCCCCC') for cat in df['category']]
|
| 193 |
+
#squarify.plot(sizes=df['count'], label=df['label'], color=colors, alpha=0.8, ax=ax)
|
| 194 |
+
squarify.plot(sizes=df['count'], label=df['label'], color=colors, alpha=0.8, ax=ax, text=df['label'])
|
| 195 |
+
squarify.plot(sizes=df['count'], label=df['label'], color=list(POS_COLORS.values())[:len(df)], alpha=0.8, ax=ax, text=df['label'])
|
| 196 |
+
df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}\n({x['count']})", axis=1)
|
| 197 |
+
plt.title('Treemap del total de palabras por categoria gramátical')
|
| 198 |
plt.axis('off')
|
| 199 |
+
print(fig)
|
| 200 |
st.pyplot(fig)
|
| 201 |
else:
|
| 202 |
st.info("No hay datos de conteo de palabras disponibles.")
|