Spaces:
Sleeping
Sleeping
Update modules/text_analysis/semantic_analysis.py
Browse files
modules/text_analysis/semantic_analysis.py
CHANGED
@@ -286,7 +286,7 @@ def create_concept_graph(doc, key_concepts):
|
|
286 |
|
287 |
###############################################################################
|
288 |
|
289 |
-
def visualize_concept_graph(G, lang_code):
|
290 |
"""
|
291 |
Visualiza el grafo de conceptos con layout consistente.
|
292 |
Args:
|
@@ -372,23 +372,21 @@ def visualize_concept_graph(G, lang_code):
|
|
372 |
ax=ax
|
373 |
)
|
374 |
#################################################################
|
375 |
-
#
|
|
|
|
|
|
|
376 |
sm = plt.cm.ScalarMappable(cmap=plt.cm.viridis, norm=plt.Normalize(vmin=0, vmax=1))
|
377 |
sm.set_array([])
|
378 |
-
plt.colorbar(sm, ax=ax
|
379 |
-
|
380 |
-
# T铆tulo traducido
|
381 |
-
plt.title(semantic_t.get('concept_network', 'Concept Network'), pad=20, fontsize=14)
|
382 |
|
383 |
-
# Ajustar el layout para que la barra de color no se superponga
|
384 |
ax.set_axis_off()
|
385 |
plt.tight_layout()
|
386 |
-
|
387 |
return fig
|
388 |
-
|
389 |
except Exception as e:
|
390 |
logger.error(f"Error en visualize_concept_graph: {str(e)}")
|
391 |
-
return plt.figure()
|
392 |
|
393 |
########################################################################
|
394 |
def create_entity_graph(entities):
|
|
|
286 |
|
287 |
###############################################################################
|
288 |
|
289 |
+
def visualize_concept_graph(G, lang_code, semantic_t):
|
290 |
"""
|
291 |
Visualiza el grafo de conceptos con layout consistente.
|
292 |
Args:
|
|
|
372 |
ax=ax
|
373 |
)
|
374 |
#################################################################
|
375 |
+
# Usar semantic_t para obtener las traducciones
|
376 |
+
plt.title(semantic_t.get('concept_network', 'Concept Network'), pad=20, fontsize=14)
|
377 |
+
|
378 |
+
# Leyenda de centralidad (traducida)
|
379 |
sm = plt.cm.ScalarMappable(cmap=plt.cm.viridis, norm=plt.Normalize(vmin=0, vmax=1))
|
380 |
sm.set_array([])
|
381 |
+
cbar = plt.colorbar(sm, ax=ax)
|
382 |
+
cbar.set_label(semantic_t.get('concept_centrality', 'Concept Centrality'))
|
|
|
|
|
383 |
|
|
|
384 |
ax.set_axis_off()
|
385 |
plt.tight_layout()
|
|
|
386 |
return fig
|
|
|
387 |
except Exception as e:
|
388 |
logger.error(f"Error en visualize_concept_graph: {str(e)}")
|
389 |
+
return plt.figure()
|
390 |
|
391 |
########################################################################
|
392 |
def create_entity_graph(entities):
|