Update modules/studentact/student_activities_v2.py
Browse files
modules/studentact/student_activities_v2.py
CHANGED
@@ -103,18 +103,32 @@ def display_semantic_activities(username: str, t: dict):
|
|
103 |
f"{t.get('analysis_date', 'Fecha')}: {analysis['timestamp']}",
|
104 |
expanded=False
|
105 |
):
|
|
|
106 |
st.text(f"{t.get('analyzed_file', 'Archivo analizado')}:")
|
107 |
st.write(analysis['text'])
|
108 |
|
|
|
109 |
if 'key_concepts' in analysis:
|
110 |
st.subheader(t.get('key_concepts', 'Conceptos clave'))
|
111 |
-
df = pd.DataFrame(
|
|
|
|
|
|
|
112 |
st.dataframe(df)
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
except Exception as e:
|
115 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
116 |
st.error(t.get('error_semantic', 'Error al mostrar análisis semántico'))
|
117 |
|
|
|
|
|
|
|
118 |
def display_discourse_activities(username: str, t: dict):
|
119 |
"""Muestra actividades de análisis del discurso"""
|
120 |
try:
|
@@ -128,6 +142,7 @@ def display_discourse_activities(username: str, t: dict):
|
|
128 |
f"{t.get('analysis_date', 'Fecha')}: {analysis['timestamp']}",
|
129 |
expanded=False
|
130 |
):
|
|
|
131 |
col1, col2 = st.columns(2)
|
132 |
with col1:
|
133 |
st.text(f"{t.get('text_1', 'Texto 1')}:")
|
@@ -136,43 +151,55 @@ def display_discourse_activities(username: str, t: dict):
|
|
136 |
st.text(f"{t.get('text_2', 'Texto 2')}:")
|
137 |
st.write(analysis['text2'])
|
138 |
|
|
|
139 |
if 'key_concepts1' in analysis and 'key_concepts2' in analysis:
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
except Exception as e:
|
143 |
logger.error(f"Error mostrando análisis del discurso: {str(e)}")
|
144 |
st.error(t.get('error_discourse', 'Error al mostrar análisis del discurso'))
|
145 |
|
146 |
-
|
147 |
-
"""Muestra historial de conversaciones del chat"""
|
148 |
-
try:
|
149 |
-
# Obtener historial con tipo por defecto 'sidebar'
|
150 |
-
chat_history = get_chat_history(
|
151 |
-
username=username,
|
152 |
-
analysis_type='sidebar',
|
153 |
-
limit=50
|
154 |
-
)
|
155 |
-
|
156 |
-
if not chat_history:
|
157 |
-
st.info(t.get('no_chat_history', 'No hay conversaciones registradas'))
|
158 |
-
return
|
159 |
-
|
160 |
-
for chat in chat_history:
|
161 |
-
with st.expander(
|
162 |
-
f"{t.get('chat_date', 'Fecha de conversación')}: {chat['timestamp']}",
|
163 |
-
expanded=False
|
164 |
-
):
|
165 |
-
if 'messages' in chat:
|
166 |
-
for message in chat['messages']:
|
167 |
-
with st.chat_message(message["role"]):
|
168 |
-
st.markdown(message["content"])
|
169 |
-
else:
|
170 |
-
st.warning(t.get('invalid_chat_format', 'Formato de chat no válido'))
|
171 |
-
|
172 |
-
except Exception as e:
|
173 |
-
logger.error(f"Error mostrando historial del chat: {str(e)}")
|
174 |
-
st.error(t.get('error_chat', 'Error al mostrar historial del chat'))
|
175 |
-
|
176 |
def display_discourse_comparison(analysis: dict, t: dict):
|
177 |
"""Muestra la comparación de análisis del discurso"""
|
178 |
st.subheader(t.get('comparison_results', 'Resultados de la comparación'))
|
@@ -188,10 +215,6 @@ def display_discourse_comparison(analysis: dict, t: dict):
|
|
188 |
df2 = pd.DataFrame(analysis['key_concepts2'])
|
189 |
st.dataframe(df2)
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
'''
|
196 |
##########versión 25-9-2024---02:30 ################ OK (username)####################
|
197 |
|
|
|
103 |
f"{t.get('analysis_date', 'Fecha')}: {analysis['timestamp']}",
|
104 |
expanded=False
|
105 |
):
|
106 |
+
# Mostrar texto analizado
|
107 |
st.text(f"{t.get('analyzed_file', 'Archivo analizado')}:")
|
108 |
st.write(analysis['text'])
|
109 |
|
110 |
+
# Mostrar conceptos clave
|
111 |
if 'key_concepts' in analysis:
|
112 |
st.subheader(t.get('key_concepts', 'Conceptos clave'))
|
113 |
+
df = pd.DataFrame(
|
114 |
+
analysis['key_concepts'],
|
115 |
+
columns=['Concepto', 'Frecuencia']
|
116 |
+
)
|
117 |
st.dataframe(df)
|
118 |
|
119 |
+
# Mostrar gráfico de conceptos
|
120 |
+
if 'concept_graph' in analysis and analysis['concept_graph']:
|
121 |
+
st.subheader(t.get('concept_graph', 'Grafo de conceptos'))
|
122 |
+
image_bytes = base64.b64decode(analysis['concept_graph'])
|
123 |
+
st.image(image_bytes)
|
124 |
+
|
125 |
except Exception as e:
|
126 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
127 |
st.error(t.get('error_semantic', 'Error al mostrar análisis semántico'))
|
128 |
|
129 |
+
###################################################################################################
|
130 |
+
|
131 |
+
|
132 |
def display_discourse_activities(username: str, t: dict):
|
133 |
"""Muestra actividades de análisis del discurso"""
|
134 |
try:
|
|
|
142 |
f"{t.get('analysis_date', 'Fecha')}: {analysis['timestamp']}",
|
143 |
expanded=False
|
144 |
):
|
145 |
+
# Mostrar textos analizados
|
146 |
col1, col2 = st.columns(2)
|
147 |
with col1:
|
148 |
st.text(f"{t.get('text_1', 'Texto 1')}:")
|
|
|
151 |
st.text(f"{t.get('text_2', 'Texto 2')}:")
|
152 |
st.write(analysis['text2'])
|
153 |
|
154 |
+
# Mostrar conceptos clave
|
155 |
if 'key_concepts1' in analysis and 'key_concepts2' in analysis:
|
156 |
+
st.subheader(t.get('comparison_results', 'Resultados de la comparación'))
|
157 |
+
|
158 |
+
col1, col2 = st.columns(2)
|
159 |
+
with col1:
|
160 |
+
st.markdown(f"**{t.get('concepts_text_1', 'Conceptos Texto 1')}**")
|
161 |
+
df1 = pd.DataFrame(
|
162 |
+
analysis['key_concepts1'],
|
163 |
+
columns=['Concepto', 'Frecuencia']
|
164 |
+
)
|
165 |
+
st.dataframe(df1)
|
166 |
+
|
167 |
+
with col2:
|
168 |
+
st.markdown(f"**{t.get('concepts_text_2', 'Conceptos Texto 2')}**")
|
169 |
+
df2 = pd.DataFrame(
|
170 |
+
analysis['key_concepts2'],
|
171 |
+
columns=['Concepto', 'Frecuencia']
|
172 |
+
)
|
173 |
+
st.dataframe(df2)
|
174 |
+
|
175 |
+
# Mostrar gráficos
|
176 |
+
if all(key in analysis for key in ['graph1', 'graph2']):
|
177 |
+
st.subheader(t.get('visualizations', 'Visualizaciones'))
|
178 |
+
|
179 |
+
col1, col2 = st.columns(2)
|
180 |
+
with col1:
|
181 |
+
st.markdown(f"**{t.get('graph_text_1', 'Grafo Texto 1')}**")
|
182 |
+
if analysis['graph1']:
|
183 |
+
image_bytes = base64.b64decode(analysis['graph1'])
|
184 |
+
st.image(image_bytes)
|
185 |
+
|
186 |
+
with col2:
|
187 |
+
st.markdown(f"**{t.get('graph_text_2', 'Grafo Texto 2')}**")
|
188 |
+
if analysis['graph2']:
|
189 |
+
image_bytes = base64.b64decode(analysis['graph2'])
|
190 |
+
st.image(image_bytes)
|
191 |
+
|
192 |
+
# Mostrar gráfico combinado si existe
|
193 |
+
if 'combined_graph' in analysis and analysis['combined_graph']:
|
194 |
+
st.subheader(t.get('combined_visualization', 'Visualización Combinada'))
|
195 |
+
image_bytes = base64.b64decode(analysis['combined_graph'])
|
196 |
+
st.image(image_bytes)
|
197 |
|
198 |
except Exception as e:
|
199 |
logger.error(f"Error mostrando análisis del discurso: {str(e)}")
|
200 |
st.error(t.get('error_discourse', 'Error al mostrar análisis del discurso'))
|
201 |
|
202 |
+
#################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
def display_discourse_comparison(analysis: dict, t: dict):
|
204 |
"""Muestra la comparación de análisis del discurso"""
|
205 |
st.subheader(t.get('comparison_results', 'Resultados de la comparación'))
|
|
|
215 |
df2 = pd.DataFrame(analysis['key_concepts2'])
|
216 |
st.dataframe(df2)
|
217 |
|
|
|
|
|
|
|
|
|
218 |
'''
|
219 |
##########versión 25-9-2024---02:30 ################ OK (username)####################
|
220 |
|