Update modules/text_analysis/morpho_analysis.py
Browse files
modules/text_analysis/morpho_analysis.py
CHANGED
@@ -119,7 +119,7 @@ def highlight_repeated_words(doc, word_colors):
|
|
119 |
|
120 |
def generate_arc_diagram(doc):
|
121 |
"""
|
122 |
-
Genera diagramas de arco para cada oraci贸n en el documento.
|
123 |
|
124 |
Args:
|
125 |
doc: Documento procesado por spaCy
|
@@ -127,25 +127,34 @@ def generate_arc_diagram(doc):
|
|
127 |
list: Lista de diagramas en formato HTML
|
128 |
"""
|
129 |
arc_diagrams = []
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
"distance": 100,
|
134 |
"color": "#ffffff",
|
135 |
"bg": "#0d6efd",
|
136 |
-
"font": "Arial"
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
|
|
|
|
|
|
|
|
149 |
|
150 |
"""
|
151 |
def generate_arc_diagram(doc):
|
|
|
119 |
|
120 |
def generate_arc_diagram(doc):
|
121 |
"""
|
122 |
+
Genera diagramas de arco para cada oraci贸n en el documento usando spacy-streamlit.
|
123 |
|
124 |
Args:
|
125 |
doc: Documento procesado por spaCy
|
|
|
127 |
list: Lista de diagramas en formato HTML
|
128 |
"""
|
129 |
arc_diagrams = []
|
130 |
+
try:
|
131 |
+
options = {
|
132 |
+
"compact": False,
|
|
|
133 |
"color": "#ffffff",
|
134 |
"bg": "#0d6efd",
|
135 |
+
"font": "Arial",
|
136 |
+
"offset_x": 50,
|
137 |
+
"distance": 100,
|
138 |
+
"arrow_spacing": 12,
|
139 |
+
"arrow_width": 2,
|
140 |
+
"arrow_stroke": 2,
|
141 |
+
"word_spacing": 25,
|
142 |
+
"maxZoom": 2
|
143 |
+
}
|
144 |
+
|
145 |
+
for sent in doc.sents:
|
146 |
+
try:
|
147 |
+
# Usar el m茅todo render de displacy directamente con las opciones
|
148 |
+
html = displacy.render(sent, style="dep", options=options)
|
149 |
+
arc_diagrams.append(html)
|
150 |
+
except Exception as e:
|
151 |
+
logger.error(f"Error al renderizar oraci贸n: {str(e)}")
|
152 |
+
continue
|
153 |
|
154 |
+
return arc_diagrams
|
155 |
+
except Exception as e:
|
156 |
+
logger.error(f"Error general en generate_arc_diagram: {str(e)}")
|
157 |
+
return None
|
158 |
|
159 |
"""
|
160 |
def generate_arc_diagram(doc):
|