Update modules/ui.py
Browse files- modules/ui.py +32 -24
modules/ui.py
CHANGED
|
@@ -187,7 +187,8 @@ def display_chat_interface():
|
|
| 187 |
st.session_state.chat_history.append(("bot", response))
|
| 188 |
st.experimental_rerun()
|
| 189 |
|
| 190 |
-
|
|
|
|
| 191 |
def display_student_progress(username, lang_code='es'):
|
| 192 |
student_data = get_student_data(username)
|
| 193 |
|
|
@@ -200,14 +201,14 @@ def display_student_progress(username, lang_code='es'):
|
|
| 200 |
|
| 201 |
if student_data['entries_count'] > 0:
|
| 202 |
# Mostrar el conteo de palabras
|
| 203 |
-
if
|
| 204 |
with st.expander("Total de palabras por categoría gramatical", expanded=False):
|
| 205 |
df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
|
| 206 |
df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}", axis=1)
|
| 207 |
df = df.sort_values('count', ascending=False)
|
| 208 |
|
| 209 |
fig, ax = plt.subplots(figsize=(12, 6))
|
| 210 |
-
bars = ax.bar(df['label'], df['count'], color=
|
| 211 |
|
| 212 |
ax.set_xlabel('Categoría Gramatical')
|
| 213 |
ax.set_ylabel('Cantidad de Palabras')
|
|
@@ -220,42 +221,44 @@ def display_student_progress(username, lang_code='es'):
|
|
| 220 |
|
| 221 |
plt.tight_layout()
|
| 222 |
st.pyplot(fig)
|
| 223 |
-
|
| 224 |
# Mostrar análisis morfosintáctico
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
|
|
|
| 228 |
st.subheader(f"Análisis {i+1} - {entry['timestamp']}")
|
| 229 |
-
st.write(entry['text'])
|
| 230 |
-
for j, diagram in enumerate(entry
|
| 231 |
st.subheader(f"Diagrama de Arco {j+1}")
|
| 232 |
st.write(diagram, unsafe_allow_html=True)
|
| 233 |
-
|
| 234 |
-
# Mostrar análisis semántico
|
| 235 |
-
if 'semantic_analyses'
|
| 236 |
with st.expander("Análisis Semántico - Diagramas de Red", expanded=False):
|
| 237 |
for i, entry in enumerate(student_data['semantic_analyses']):
|
| 238 |
st.subheader(f"Análisis Semántico {i+1} - {entry['timestamp']}")
|
| 239 |
-
st.write(entry['text'])
|
| 240 |
if 'network_diagram' in entry:
|
| 241 |
image_bytes = base64.b64decode(entry['network_diagram'])
|
| 242 |
st.image(image_bytes)
|
| 243 |
-
|
| 244 |
-
# Mostrar análisis del discurso
|
| 245 |
-
if 'discourse_analyses'
|
| 246 |
with st.expander("Análisis del Discurso - Comparación de Grafos", expanded=False):
|
| 247 |
for i, entry in enumerate(student_data['discourse_analyses']):
|
| 248 |
st.subheader(f"Análisis del Discurso {i+1} - {entry['timestamp']}")
|
| 249 |
st.write("Texto del documento patrón:")
|
| 250 |
-
st.write(entry
|
| 251 |
st.write("Texto del documento comparado:")
|
| 252 |
-
st.write(entry
|
| 253 |
-
if '
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
|
|
|
| 259 |
with st.expander("Historial de Conversaciones del Chat", expanded=False):
|
| 260 |
for i, chat in enumerate(student_data['chat_history']):
|
| 261 |
st.subheader(f"Conversación {i+1} - {chat['timestamp']}")
|
|
@@ -269,6 +272,11 @@ def display_student_progress(username, lang_code='es'):
|
|
| 269 |
st.warning("No se encontraron entradas para este estudiante.")
|
| 270 |
st.info("Intenta realizar algunos análisis de texto primero.")
|
| 271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
##################################################################################################
|
| 273 |
def display_morphosyntax_analysis_interface(nlp_models, lang_code):
|
| 274 |
translations = {
|
|
|
|
| 187 |
st.session_state.chat_history.append(("bot", response))
|
| 188 |
st.experimental_rerun()
|
| 189 |
|
| 190 |
+
################################################################################
|
| 191 |
+
# Funciones para Cosmos DB MongoDB API (análisis de texto)
|
| 192 |
def display_student_progress(username, lang_code='es'):
|
| 193 |
student_data = get_student_data(username)
|
| 194 |
|
|
|
|
| 201 |
|
| 202 |
if student_data['entries_count'] > 0:
|
| 203 |
# Mostrar el conteo de palabras
|
| 204 |
+
if student_data['word_count']:
|
| 205 |
with st.expander("Total de palabras por categoría gramatical", expanded=False):
|
| 206 |
df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
|
| 207 |
df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}", axis=1)
|
| 208 |
df = df.sort_values('count', ascending=False)
|
| 209 |
|
| 210 |
fig, ax = plt.subplots(figsize=(12, 6))
|
| 211 |
+
bars = ax.bar(df['label'], df['count'], color=df['category'])
|
| 212 |
|
| 213 |
ax.set_xlabel('Categoría Gramatical')
|
| 214 |
ax.set_ylabel('Cantidad de Palabras')
|
|
|
|
| 221 |
|
| 222 |
plt.tight_layout()
|
| 223 |
st.pyplot(fig)
|
| 224 |
+
|
| 225 |
# Mostrar análisis morfosintáctico
|
| 226 |
+
morphosyntax_entries = [entry for entry in student_data['entries'] if entry['analysis_type'] == 'morphosyntax']
|
| 227 |
+
if morphosyntax_entries:
|
| 228 |
+
with st.expander("Análisis Morfosintáctico - Diagramas de Arco", expanded=False):
|
| 229 |
+
for i, entry in enumerate(morphosyntax_entries):
|
| 230 |
st.subheader(f"Análisis {i+1} - {entry['timestamp']}")
|
| 231 |
+
st.write(entry['text'])
|
| 232 |
+
for j, diagram in enumerate(entry.get('arc_diagrams', [])):
|
| 233 |
st.subheader(f"Diagrama de Arco {j+1}")
|
| 234 |
st.write(diagram, unsafe_allow_html=True)
|
| 235 |
+
|
| 236 |
+
# Mostrar análisis semántico
|
| 237 |
+
if student_data['semantic_analyses']:
|
| 238 |
with st.expander("Análisis Semántico - Diagramas de Red", expanded=False):
|
| 239 |
for i, entry in enumerate(student_data['semantic_analyses']):
|
| 240 |
st.subheader(f"Análisis Semántico {i+1} - {entry['timestamp']}")
|
| 241 |
+
st.write(entry['text'])
|
| 242 |
if 'network_diagram' in entry:
|
| 243 |
image_bytes = base64.b64decode(entry['network_diagram'])
|
| 244 |
st.image(image_bytes)
|
| 245 |
+
|
| 246 |
+
# Mostrar análisis del discurso
|
| 247 |
+
if student_data['discourse_analyses']:
|
| 248 |
with st.expander("Análisis del Discurso - Comparación de Grafos", expanded=False):
|
| 249 |
for i, entry in enumerate(student_data['discourse_analyses']):
|
| 250 |
st.subheader(f"Análisis del Discurso {i+1} - {entry['timestamp']}")
|
| 251 |
st.write("Texto del documento patrón:")
|
| 252 |
+
st.write(entry.get('text1', 'No disponible'))
|
| 253 |
st.write("Texto del documento comparado:")
|
| 254 |
+
st.write(entry.get('text2', 'No disponible'))
|
| 255 |
+
if 'graph1' in entry:
|
| 256 |
+
st.image(base64.b64decode(entry['graph1']))
|
| 257 |
+
if 'graph2' in entry:
|
| 258 |
+
st.image(base64.b64decode(entry['graph2']))
|
| 259 |
+
|
| 260 |
+
# Mostrar conversaciones del chat
|
| 261 |
+
if student_data['chat_history']:
|
| 262 |
with st.expander("Historial de Conversaciones del Chat", expanded=False):
|
| 263 |
for i, chat in enumerate(student_data['chat_history']):
|
| 264 |
st.subheader(f"Conversación {i+1} - {chat['timestamp']}")
|
|
|
|
| 272 |
st.warning("No se encontraron entradas para este estudiante.")
|
| 273 |
st.info("Intenta realizar algunos análisis de texto primero.")
|
| 274 |
|
| 275 |
+
# Añadir logs para depuración
|
| 276 |
+
st.write("Datos del estudiante (para depuración):")
|
| 277 |
+
st.json(student_data)
|
| 278 |
+
|
| 279 |
+
|
| 280 |
##################################################################################################
|
| 281 |
def display_morphosyntax_analysis_interface(nlp_models, lang_code):
|
| 282 |
translations = {
|