Update modules/text_analysis/morpho_analysis.py
Browse files
modules/text_analysis/morpho_analysis.py
CHANGED
@@ -117,6 +117,37 @@ def highlight_repeated_words(doc, word_colors):
|
|
117 |
|
118 |
#################################################################################################
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
def generate_arc_diagram(doc):
|
121 |
sentences = list(doc.sents)
|
122 |
arc_diagrams = []
|
@@ -128,7 +159,7 @@ def generate_arc_diagram(doc):
|
|
128 |
arc_diagrams.append(html)
|
129 |
return arc_diagrams
|
130 |
|
131 |
-
|
132 |
def generate_arc_diagram(doc):
|
133 |
|
134 |
Genera diagramas de arco para cada oraci贸n en el documento.
|
|
|
117 |
|
118 |
#################################################################################################
|
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
|
126 |
+
Returns:
|
127 |
+
list: Lista de diagramas en formato HTML
|
128 |
+
"""
|
129 |
+
arc_diagrams = []
|
130 |
+
for sent in doc.sents:
|
131 |
+
# Configuraci贸n b谩sica que sabemos que funciona
|
132 |
+
html = displacy.render(sent, style="dep", options={
|
133 |
+
"distance": 100,
|
134 |
+
"color": "#ffffff",
|
135 |
+
"bg": "#0d6efd",
|
136 |
+
"font": "Arial"
|
137 |
+
})
|
138 |
+
|
139 |
+
# Ajustes b谩sicos que funcionaban en la versi贸n anterior
|
140 |
+
html = html.replace('height="375"', 'height="200"')
|
141 |
+
html = re.sub(r'<svg[^>]*>', lambda m: m.group(0).replace('height="450"', 'height="300"'), html)
|
142 |
+
html = re.sub(r'<g [^>]*transform="translate\((\d+),(\d+)\)"',
|
143 |
+
lambda m: f'<g transform="translate({m.group(1)},50)"', html)
|
144 |
+
|
145 |
+
arc_diagrams.append(html)
|
146 |
+
|
147 |
+
return arc_diagrams
|
148 |
+
|
149 |
+
|
150 |
+
"""
|
151 |
def generate_arc_diagram(doc):
|
152 |
sentences = list(doc.sents)
|
153 |
arc_diagrams = []
|
|
|
159 |
arc_diagrams.append(html)
|
160 |
return arc_diagrams
|
161 |
|
162 |
+
|
163 |
def generate_arc_diagram(doc):
|
164 |
|
165 |
Genera diagramas de arco para cada oraci贸n en el documento.
|