Spaces:
Sleeping
Sleeping
Update modules/semantic/semantic_interface.py
Browse files
modules/semantic/semantic_interface.py
CHANGED
|
@@ -141,71 +141,65 @@ def display_semantic_interface(lang_code, nlp_models, semantic_t):
|
|
| 141 |
#######################################
|
| 142 |
def display_semantic_results(semantic_result, lang_code, semantic_t):
|
| 143 |
"""
|
| 144 |
-
Muestra los resultados del análisis semántico
|
|
|
|
| 145 |
Args:
|
| 146 |
semantic_result: Diccionario con los resultados del análisis
|
| 147 |
lang_code: Código del idioma actual
|
| 148 |
semantic_t: Diccionario de traducciones semánticas
|
| 149 |
"""
|
| 150 |
-
# Verificar resultado
|
| 151 |
if semantic_result is None or not semantic_result['success']:
|
| 152 |
st.warning(semantic_t.get('no_results', 'No results available'))
|
| 153 |
return
|
| 154 |
-
|
| 155 |
-
# Usar semantic_result en lugar de result
|
| 156 |
analysis = semantic_result['analysis']
|
| 157 |
-
|
| 158 |
-
# Crear
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
else:
|
| 200 |
-
st.info(semantic_t.get('no_entities', 'No entities found'))
|
| 201 |
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
if 'entity_graph' in analysis:
|
| 206 |
-
st.image(analysis['entity_graph'])
|
| 207 |
-
else:
|
| 208 |
-
st.info(semantic_t.get('no_entity_graph', 'No entity graph available'))
|
| 209 |
|
| 210 |
'''
|
| 211 |
# Botón de exportación al final
|
|
|
|
| 141 |
#######################################
|
| 142 |
def display_semantic_results(semantic_result, lang_code, semantic_t):
|
| 143 |
"""
|
| 144 |
+
Muestra los resultados del análisis semántico de conceptos clave.
|
| 145 |
+
|
| 146 |
Args:
|
| 147 |
semantic_result: Diccionario con los resultados del análisis
|
| 148 |
lang_code: Código del idioma actual
|
| 149 |
semantic_t: Diccionario de traducciones semánticas
|
| 150 |
"""
|
| 151 |
+
# Verificar resultado
|
| 152 |
if semantic_result is None or not semantic_result['success']:
|
| 153 |
st.warning(semantic_t.get('no_results', 'No results available'))
|
| 154 |
return
|
| 155 |
+
|
|
|
|
| 156 |
analysis = semantic_result['analysis']
|
| 157 |
+
|
| 158 |
+
# Crear contenedor para los resultados
|
| 159 |
+
col1, col2 = st.columns(2)
|
| 160 |
+
|
| 161 |
+
# Columna 1: Lista de conceptos clave
|
| 162 |
+
with col1:
|
| 163 |
+
st.subheader(semantic_t.get('key_concepts', 'Key Concepts'))
|
| 164 |
+
if 'key_concepts' in analysis and analysis['key_concepts']:
|
| 165 |
+
# Crear tabla de conceptos
|
| 166 |
+
df = pd.DataFrame(
|
| 167 |
+
analysis['key_concepts'],
|
| 168 |
+
columns=[
|
| 169 |
+
semantic_t.get('concept', 'Concept'),
|
| 170 |
+
semantic_t.get('frequency', 'Frequency')
|
| 171 |
+
]
|
| 172 |
+
)
|
| 173 |
+
st.dataframe(
|
| 174 |
+
df,
|
| 175 |
+
hide_index=True,
|
| 176 |
+
column_config={
|
| 177 |
+
semantic_t.get('frequency', 'Frequency'): st.column_config.NumberColumn(
|
| 178 |
+
format="%.2f"
|
| 179 |
+
)
|
| 180 |
+
}
|
| 181 |
+
)
|
| 182 |
+
else:
|
| 183 |
+
st.info(semantic_t.get('no_concepts', 'No key concepts found'))
|
| 184 |
+
|
| 185 |
+
# Columna 2: Gráfico de conceptos
|
| 186 |
+
with col2:
|
| 187 |
+
st.subheader(semantic_t.get('concept_graph', 'Concepts Graph'))
|
| 188 |
+
if 'concept_graph' in analysis and analysis['concept_graph'] is not None:
|
| 189 |
+
st.image(analysis['concept_graph'])
|
| 190 |
+
else:
|
| 191 |
+
st.info(semantic_t.get('no_graph', 'No concept graph available'))
|
| 192 |
+
|
| 193 |
+
# Agregar explicación del análisis
|
| 194 |
+
with st.expander(semantic_t.get('analysis_explanation', 'About this analysis')):
|
| 195 |
+
st.markdown(semantic_t.get('concepts_explanation', """
|
| 196 |
+
This analysis shows the most important concepts in your text and their relationships:
|
| 197 |
+
- **Key Concepts**: Shows the main concepts and their frequency in the text
|
| 198 |
+
- **Concept Graph**: Visualizes how these concepts are related to each other
|
|
|
|
|
|
|
| 199 |
|
| 200 |
+
The larger nodes in the graph represent concepts that appear more frequently or have
|
| 201 |
+
more connections to other concepts.
|
| 202 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
'''
|
| 205 |
# Botón de exportación al final
|