Spaces:
Sleeping
Sleeping
Update modules/semantic/semantic_live_interface.py
Browse files
modules/semantic/semantic_live_interface.py
CHANGED
|
@@ -112,7 +112,7 @@ def display_semantic_live_interface(lang_code, nlp_models, semantic_t):
|
|
| 112 |
st.warning(semantic_t.get('text_changed_warning',
|
| 113 |
'El texto ha cambiado. Presione Analizar para actualizar los resultados.'))
|
| 114 |
|
| 115 |
-
|
| 116 |
if 'key_concepts' in analysis and analysis['key_concepts']:
|
| 117 |
st.markdown("""
|
| 118 |
<style>
|
|
@@ -120,10 +120,10 @@ def display_semantic_live_interface(lang_code, nlp_models, semantic_t):
|
|
| 120 |
display: flex;
|
| 121 |
flex-wrap: wrap;
|
| 122 |
gap: 10px;
|
| 123 |
-
margin-bottom: 20px;
|
| 124 |
padding: 10px;
|
| 125 |
background-color: #f8f9fa;
|
| 126 |
-
border-radius: 8px;
|
|
|
|
| 127 |
}
|
| 128 |
.concept-item {
|
| 129 |
background-color: white;
|
|
@@ -142,9 +142,27 @@ def display_semantic_live_interface(lang_code, nlp_models, semantic_t):
|
|
| 142 |
color: #6b7280;
|
| 143 |
font-size: 0.9em;
|
| 144 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
</style>
|
| 146 |
""", unsafe_allow_html=True)
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
concepts_html = ['<div class="concept-table">']
|
| 149 |
concepts_html.extend(
|
| 150 |
f'<div class="concept-item"><span class="concept-name">{concept}</span>'
|
|
@@ -155,22 +173,10 @@ def display_semantic_live_interface(lang_code, nlp_models, semantic_t):
|
|
| 155 |
|
| 156 |
st.markdown(''.join(concepts_html), unsafe_allow_html=True)
|
| 157 |
|
| 158 |
-
# Mostrar gráfico de conceptos en
|
| 159 |
if 'concept_graph' in analysis and analysis['concept_graph'] is not None:
|
| 160 |
with st.container():
|
| 161 |
-
st.markdown(""
|
| 162 |
-
<style>
|
| 163 |
-
.graph-container {
|
| 164 |
-
background-color: white;
|
| 165 |
-
border-radius: 10px;
|
| 166 |
-
padding: 20px;
|
| 167 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 168 |
-
margin: 10px 0;
|
| 169 |
-
min-height: 400px;
|
| 170 |
-
}
|
| 171 |
-
</style>
|
| 172 |
-
<div class="graph-container">
|
| 173 |
-
""", unsafe_allow_html=True)
|
| 174 |
|
| 175 |
st.image(
|
| 176 |
analysis['concept_graph'],
|
|
@@ -180,8 +186,6 @@ def display_semantic_live_interface(lang_code, nlp_models, semantic_t):
|
|
| 180 |
'Visualización de relaciones entre conceptos clave identificados en el texto.'
|
| 181 |
)
|
| 182 |
)
|
| 183 |
-
|
| 184 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
| 185 |
|
| 186 |
# Contenedor para botones en la parte inferior del gráfico
|
| 187 |
button_col, spacer_col = st.columns([1,4])
|
|
@@ -202,10 +206,8 @@ def display_semantic_live_interface(lang_code, nlp_models, semantic_t):
|
|
| 202 |
- ⭕ El tamaño de los nodos representa la frecuencia del concepto
|
| 203 |
- ↔️ El grosor de las líneas indica la fuerza de la conexión
|
| 204 |
""")
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
except Exception as e:
|
| 209 |
-
logger.error(f"Error general en interfaz semántica en vivo: {str(e)}")
|
| 210 |
-
st.error(semantic_t.get('general_error', "Se produjo un error. Por favor, intente de nuevo."))
|
| 211 |
|
|
|
|
|
|
|
|
|
| 112 |
st.warning(semantic_t.get('text_changed_warning',
|
| 113 |
'El texto ha cambiado. Presione Analizar para actualizar los resultados.'))
|
| 114 |
|
| 115 |
+
# Mostrar conceptos clave en formato horizontal
|
| 116 |
if 'key_concepts' in analysis and analysis['key_concepts']:
|
| 117 |
st.markdown("""
|
| 118 |
<style>
|
|
|
|
| 120 |
display: flex;
|
| 121 |
flex-wrap: wrap;
|
| 122 |
gap: 10px;
|
|
|
|
| 123 |
padding: 10px;
|
| 124 |
background-color: #f8f9fa;
|
| 125 |
+
border-radius: 8px 8px 0 0;
|
| 126 |
+
margin-bottom: 0;
|
| 127 |
}
|
| 128 |
.concept-item {
|
| 129 |
background-color: white;
|
|
|
|
| 142 |
color: #6b7280;
|
| 143 |
font-size: 0.9em;
|
| 144 |
}
|
| 145 |
+
.graph-container {
|
| 146 |
+
background-color: white;
|
| 147 |
+
border-radius: 0 0 10px 10px;
|
| 148 |
+
padding: 20px;
|
| 149 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 150 |
+
margin-top: 0;
|
| 151 |
+
min-height: 400px;
|
| 152 |
+
}
|
| 153 |
+
.results-container {
|
| 154 |
+
background-color: white;
|
| 155 |
+
border-radius: 10px;
|
| 156 |
+
overflow: hidden;
|
| 157 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 158 |
+
}
|
| 159 |
</style>
|
| 160 |
""", unsafe_allow_html=True)
|
| 161 |
|
| 162 |
+
# Iniciar contenedor principal
|
| 163 |
+
st.markdown('<div class="results-container">', unsafe_allow_html=True)
|
| 164 |
+
|
| 165 |
+
# Crear la visualización horizontal de conceptos
|
| 166 |
concepts_html = ['<div class="concept-table">']
|
| 167 |
concepts_html.extend(
|
| 168 |
f'<div class="concept-item"><span class="concept-name">{concept}</span>'
|
|
|
|
| 173 |
|
| 174 |
st.markdown(''.join(concepts_html), unsafe_allow_html=True)
|
| 175 |
|
| 176 |
+
# Mostrar gráfico de conceptos en el mismo contenedor
|
| 177 |
if 'concept_graph' in analysis and analysis['concept_graph'] is not None:
|
| 178 |
with st.container():
|
| 179 |
+
st.markdown('<div class="graph-container">', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
st.image(
|
| 182 |
analysis['concept_graph'],
|
|
|
|
| 186 |
'Visualización de relaciones entre conceptos clave identificados en el texto.'
|
| 187 |
)
|
| 188 |
)
|
|
|
|
|
|
|
| 189 |
|
| 190 |
# Contenedor para botones en la parte inferior del gráfico
|
| 191 |
button_col, spacer_col = st.columns([1,4])
|
|
|
|
| 206 |
- ⭕ El tamaño de los nodos representa la frecuencia del concepto
|
| 207 |
- ↔️ El grosor de las líneas indica la fuerza de la conexión
|
| 208 |
""")
|
| 209 |
+
|
| 210 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
+
# Cerrar el contenedor principal
|
| 213 |
+
st.markdown('</div>', unsafe_allow_html=True)
|