AIdeaText commited on
Commit
7e3e643
·
verified ·
1 Parent(s): df3c320

Update modules/semantic/semantic_interface.py

Browse files
modules/semantic/semantic_interface.py CHANGED
@@ -140,4 +140,72 @@ def display_semantic_interface(lang_code, nlp_models, semantic_t):
140
  logger.error(f"Error general en interfaz semántica: {str(e)}")
141
  st.error("Se produjo un error. Por favor, intente de nuevo.")
142
 
143
- # [Resto del código igual...]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  logger.error(f"Error general en interfaz semántica: {str(e)}")
141
  st.error("Se produjo un error. Por favor, intente de nuevo.")
142
 
143
+ # [Resto del código igual...]
144
+
145
+ def display_semantic_results(result, lang_code, semantic_t):
146
+ """
147
+ Muestra los resultados del análisis semántico en tabs
148
+ """
149
+ if result is None or not result['success']:
150
+ st.warning(semantic_t.get('no_results', 'No results available'))
151
+ return
152
+
153
+ analysis = result['analysis']
154
+
155
+ # Crear tabs para los resultados
156
+ tab1, tab2 = st.tabs([
157
+ semantic_t.get('concepts_tab', 'Key Concepts Analysis'),
158
+ semantic_t.get('entities_tab', 'Entities Analysis')
159
+ ])
160
+
161
+ # Tab 1: Conceptos Clave
162
+ with tab1:
163
+ col1, col2 = st.columns(2)
164
+
165
+ # Columna 1: Lista de conceptos
166
+ with col1:
167
+ st.subheader(semantic_t.get('key_concepts', 'Key Concepts'))
168
+ concept_text = "\n".join([
169
+ f"• {concept} ({frequency:.2f})"
170
+ for concept, frequency in analysis['key_concepts']
171
+ ])
172
+ st.markdown(concept_text)
173
+
174
+ # Columna 2: Gráfico de conceptos
175
+ with col2:
176
+ st.subheader(semantic_t.get('concept_graph', 'Concepts Graph'))
177
+ st.image(analysis['concept_graph'])
178
+
179
+ # Tab 2: Entidades
180
+ with tab2:
181
+ col1, col2 = st.columns(2)
182
+
183
+ # Columna 1: Lista de entidades
184
+ with col1:
185
+ st.subheader(semantic_t.get('identified_entities', 'Identified Entities'))
186
+ if 'entities' in analysis:
187
+ for entity_type, entities in analysis['entities'].items():
188
+ st.markdown(f"**{entity_type}**")
189
+ st.markdown("• " + "\n• ".join(entities))
190
+
191
+ # Columna 2: Gráfico de entidades
192
+ with col2:
193
+ st.subheader(semantic_t.get('entity_graph', 'Entities Graph'))
194
+ st.image(analysis['entity_graph'])
195
+
196
+ # Botón de exportación al final
197
+ col1, col2, col3 = st.columns([2,1,2])
198
+ with col2:
199
+ if st.button(
200
+ semantic_t.get('export_button', 'Export Analysis'),
201
+ key=f"semantic_export_{st.session_state.semantic_analysis_counter}",
202
+ use_container_width=True
203
+ ):
204
+ pdf_buffer = export_user_interactions(st.session_state.username, 'semantic')
205
+ st.download_button(
206
+ label=semantic_t.get('download_pdf', 'Download PDF'),
207
+ data=pdf_buffer,
208
+ file_name="semantic_analysis.pdf",
209
+ mime="application/pdf",
210
+ key=f"semantic_download_{st.session_state.semantic_analysis_counter}"
211
+ )