Update modules/ui.py
Browse files- modules/ui.py +17 -16
modules/ui.py
CHANGED
@@ -172,28 +172,30 @@ def display_student_progress(username, lang_code='es'):
|
|
172 |
|
173 |
if student_data['entries_count'] > 0:
|
174 |
if 'word_count' in student_data and student_data['word_count']:
|
175 |
-
st.subheader("Total de palabras por
|
176 |
|
177 |
df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
|
178 |
-
df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}
|
179 |
|
180 |
-
|
181 |
-
|
182 |
|
183 |
-
|
|
|
184 |
|
185 |
-
|
186 |
-
|
|
|
|
|
187 |
|
188 |
-
|
189 |
-
for
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
|
195 |
-
plt.
|
196 |
-
plt.axis('off')
|
197 |
|
198 |
buf = io.BytesIO()
|
199 |
fig.savefig(buf, format='png')
|
@@ -226,7 +228,6 @@ def display_student_progress(username, lang_code='es'):
|
|
226 |
st.warning("No se encontraron entradas para este estudiante.")
|
227 |
st.info("Intenta realizar algunos análisis de texto primero.")
|
228 |
|
229 |
-
|
230 |
##############################################################Mostrar entradas recientes######################################################################
|
231 |
#st.header("Entradas Recientes")
|
232 |
#for i, entry in enumerate(student_data['entries'][:5]): # Mostrar las 5 entradas más recientes
|
|
|
172 |
|
173 |
if student_data['entries_count'] > 0:
|
174 |
if 'word_count' in student_data and student_data['word_count']:
|
175 |
+
st.subheader("Total de palabras por categoría gramatical")
|
176 |
|
177 |
df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
|
178 |
+
df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}", axis=1)
|
179 |
|
180 |
+
# Ordenar el DataFrame por conteo de palabras, de mayor a menor
|
181 |
+
df = df.sort_values('count', ascending=False)
|
182 |
|
183 |
+
fig, ax = plt.subplots(figsize=(12, 6))
|
184 |
+
bars = ax.bar(df['label'], df['count'], color=[POS_COLORS.get(cat, '#CCCCCC') for cat in df['category']])
|
185 |
|
186 |
+
ax.set_xlabel('Categoría Gramatical')
|
187 |
+
ax.set_ylabel('Cantidad de Palabras')
|
188 |
+
ax.set_title('Total de palabras por categoría gramatical')
|
189 |
+
plt.xticks(rotation=45, ha='right')
|
190 |
|
191 |
+
# Añadir etiquetas de valor en las barras
|
192 |
+
for bar in bars:
|
193 |
+
height = bar.get_height()
|
194 |
+
ax.text(bar.get_x() + bar.get_width()/2., height,
|
195 |
+
f'{height}',
|
196 |
+
ha='center', va='bottom')
|
197 |
|
198 |
+
plt.tight_layout()
|
|
|
199 |
|
200 |
buf = io.BytesIO()
|
201 |
fig.savefig(buf, format='png')
|
|
|
228 |
st.warning("No se encontraron entradas para este estudiante.")
|
229 |
st.info("Intenta realizar algunos análisis de texto primero.")
|
230 |
|
|
|
231 |
##############################################################Mostrar entradas recientes######################################################################
|
232 |
#st.header("Entradas Recientes")
|
233 |
#for i, entry in enumerate(student_data['entries'][:5]): # Mostrar las 5 entradas más recientes
|