Spaces:
Running
Running
Update modules/semantic/semantic_interface.py
Browse files
modules/semantic/semantic_interface.py
CHANGED
|
@@ -142,6 +142,7 @@ def display_semantic_interface(lang_code, nlp_models, semantic_t):
|
|
| 142 |
|
| 143 |
|
| 144 |
#######################################
|
|
|
|
| 145 |
def display_semantic_results(semantic_result, lang_code, semantic_t):
|
| 146 |
"""
|
| 147 |
Muestra los resultados del an谩lisis sem谩ntico de conceptos clave.
|
|
@@ -152,10 +153,9 @@ def display_semantic_results(semantic_result, lang_code, semantic_t):
|
|
| 152 |
|
| 153 |
analysis = semantic_result['analysis']
|
| 154 |
|
| 155 |
-
# Mostrar conceptos clave en formato horizontal
|
| 156 |
st.subheader(semantic_t.get('key_concepts', 'Key Concepts'))
|
| 157 |
if 'key_concepts' in analysis and analysis['key_concepts']:
|
| 158 |
-
# Crear tabla de conceptos
|
| 159 |
df = pd.DataFrame(
|
| 160 |
analysis['key_concepts'],
|
| 161 |
columns=[
|
|
@@ -164,7 +164,6 @@ def display_semantic_results(semantic_result, lang_code, semantic_t):
|
|
| 164 |
]
|
| 165 |
)
|
| 166 |
|
| 167 |
-
# Convertir DataFrame a formato horizontal
|
| 168 |
st.write(
|
| 169 |
"""
|
| 170 |
<style>
|
|
@@ -203,53 +202,27 @@ def display_semantic_results(semantic_result, lang_code, semantic_t):
|
|
| 203 |
else:
|
| 204 |
st.info(semantic_t.get('no_concepts', 'No key concepts found'))
|
| 205 |
|
| 206 |
-
# Gr谩fico de conceptos
|
| 207 |
-
# st.subheader(semantic_t.get('concept_graph', 'Concepts Graph'))
|
| 208 |
-
#Colocar aqu铆 el bloque de c贸digo
|
| 209 |
if 'concept_graph' in analysis and analysis['concept_graph'] is not None:
|
| 210 |
try:
|
| 211 |
-
#
|
| 212 |
-
st.
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
.graph-container {
|
| 216 |
-
background-color: white;
|
| 217 |
-
border-radius: 10px;
|
| 218 |
-
padding: 20px;
|
| 219 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 220 |
-
margin: 10px 0;
|
| 221 |
-
}
|
| 222 |
-
.button-container {
|
| 223 |
-
display: flex;
|
| 224 |
-
gap: 10px;
|
| 225 |
-
margin: 10px 0;
|
| 226 |
-
}
|
| 227 |
-
</style>
|
| 228 |
-
""",
|
| 229 |
-
unsafe_allow_html=True
|
| 230 |
)
|
| 231 |
-
#Colocar aqu铆 el bloque de c贸digo
|
| 232 |
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
# Leyenda del grafo
|
| 245 |
-
#st.caption(semantic_t.get(
|
| 246 |
-
# 'graph_description',
|
| 247 |
-
# 'Visualizaci贸n de relaciones entre conceptos clave identificados en el texto.'
|
| 248 |
-
#))
|
| 249 |
-
|
| 250 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
| 251 |
|
| 252 |
-
# Expandible con la interpretaci贸n
|
| 253 |
with st.expander("馃搳 " + semantic_t.get('semantic_graph_interpretation', "Interpretaci贸n del gr谩fico sem谩ntico")):
|
| 254 |
st.markdown(f"""
|
| 255 |
- 馃攢 {semantic_t.get('semantic_arrow_meaning', 'Las flechas indican la direcci贸n de la relaci贸n entre conceptos')}
|
|
@@ -258,19 +231,30 @@ def display_semantic_results(semantic_result, lang_code, semantic_t):
|
|
| 258 |
- 鈫旓笍 {semantic_t.get('semantic_thickness_meaning', 'El grosor de las l铆neas indica la fuerza de la conexi贸n')}
|
| 259 |
""")
|
| 260 |
|
| 261 |
-
# Contenedor para botones
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
|
| 272 |
except Exception as e:
|
| 273 |
logger.error(f"Error displaying graph: {str(e)}")
|
| 274 |
st.error(semantic_t.get('graph_error', 'Error displaying the graph'))
|
| 275 |
else:
|
| 276 |
-
st.info(semantic_t.get('no_graph', 'No concept graph available'))
|
|
|
|
| 142 |
|
| 143 |
|
| 144 |
#######################################
|
| 145 |
+
|
| 146 |
def display_semantic_results(semantic_result, lang_code, semantic_t):
|
| 147 |
"""
|
| 148 |
Muestra los resultados del an谩lisis sem谩ntico de conceptos clave.
|
|
|
|
| 153 |
|
| 154 |
analysis = semantic_result['analysis']
|
| 155 |
|
| 156 |
+
# Mostrar conceptos clave en formato horizontal (se mantiene igual)
|
| 157 |
st.subheader(semantic_t.get('key_concepts', 'Key Concepts'))
|
| 158 |
if 'key_concepts' in analysis and analysis['key_concepts']:
|
|
|
|
| 159 |
df = pd.DataFrame(
|
| 160 |
analysis['key_concepts'],
|
| 161 |
columns=[
|
|
|
|
| 164 |
]
|
| 165 |
)
|
| 166 |
|
|
|
|
| 167 |
st.write(
|
| 168 |
"""
|
| 169 |
<style>
|
|
|
|
| 202 |
else:
|
| 203 |
st.info(semantic_t.get('no_concepts', 'No key concepts found'))
|
| 204 |
|
| 205 |
+
# Gr谩fico de conceptos (versi贸n modificada)
|
|
|
|
|
|
|
| 206 |
if 'concept_graph' in analysis and analysis['concept_graph'] is not None:
|
| 207 |
try:
|
| 208 |
+
# Secci贸n del gr谩fico (sin div contenedor)
|
| 209 |
+
st.image(
|
| 210 |
+
analysis['concept_graph'],
|
| 211 |
+
use_container_width=True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
)
|
|
|
|
| 213 |
|
| 214 |
+
# --- SOLO ESTE BLOQUE ES NUEVO ---
|
| 215 |
+
st.markdown("""
|
| 216 |
+
<style>
|
| 217 |
+
div[data-testid="stExpander"] div[role="button"] p {
|
| 218 |
+
text-align: center;
|
| 219 |
+
font-weight: bold;
|
| 220 |
+
}
|
| 221 |
+
</style>
|
| 222 |
+
""", unsafe_allow_html=True)
|
| 223 |
+
# ---------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
+
# Expandible con la interpretaci贸n (se mantiene igual)
|
| 226 |
with st.expander("馃搳 " + semantic_t.get('semantic_graph_interpretation', "Interpretaci贸n del gr谩fico sem谩ntico")):
|
| 227 |
st.markdown(f"""
|
| 228 |
- 馃攢 {semantic_t.get('semantic_arrow_meaning', 'Las flechas indican la direcci贸n de la relaci贸n entre conceptos')}
|
|
|
|
| 231 |
- 鈫旓笍 {semantic_t.get('semantic_thickness_meaning', 'El grosor de las l铆neas indica la fuerza de la conexi贸n')}
|
| 232 |
""")
|
| 233 |
|
| 234 |
+
# Contenedor para botones (se mantiene igual pero centrado)
|
| 235 |
+
st.markdown("""
|
| 236 |
+
<style>
|
| 237 |
+
.download-btn-container {
|
| 238 |
+
display: flex;
|
| 239 |
+
justify-content: center;
|
| 240 |
+
margin-top: 10px;
|
| 241 |
+
}
|
| 242 |
+
</style>
|
| 243 |
+
<div class="download-btn-container">
|
| 244 |
+
""", unsafe_allow_html=True)
|
| 245 |
+
|
| 246 |
+
st.download_button(
|
| 247 |
+
label="馃摜 " + semantic_t.get('download_semantic_network_graph', "Descargar gr谩fico de red sem谩ntica"),
|
| 248 |
+
data=analysis['concept_graph'],
|
| 249 |
+
file_name="semantic_graph.png",
|
| 250 |
+
mime="image/png",
|
| 251 |
+
use_container_width=True
|
| 252 |
+
)
|
| 253 |
+
|
| 254 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 255 |
|
| 256 |
except Exception as e:
|
| 257 |
logger.error(f"Error displaying graph: {str(e)}")
|
| 258 |
st.error(semantic_t.get('graph_error', 'Error displaying the graph'))
|
| 259 |
else:
|
| 260 |
+
st.info(semantic_t.get('no_graph', 'No concept graph available'))
|