Update modules/text_analysis/morpho_analysis.py
Browse files
modules/text_analysis/morpho_analysis.py
CHANGED
@@ -116,15 +116,28 @@ def highlight_repeated_words(doc, word_colors):
|
|
116 |
return ' '.join(highlighted_text)
|
117 |
|
118 |
#################################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
def generate_arc_diagram(doc):
|
120 |
-
|
121 |
Genera diagramas de arco para cada oraci贸n en el documento.
|
122 |
|
123 |
Args:
|
124 |
doc: Documento procesado por spaCy
|
125 |
Returns:
|
126 |
list: Lista de diagramas en formato HTML
|
127 |
-
|
128 |
arc_diagrams = []
|
129 |
for sent in doc.sents:
|
130 |
words = [token.text for token in sent]
|
@@ -181,7 +194,10 @@ def generate_arc_diagram(doc):
|
|
181 |
|
182 |
arc_diagrams.append(html)
|
183 |
return arc_diagrams
|
|
|
|
|
184 |
|
|
|
185 |
#################################################################################################
|
186 |
def get_detailed_pos_analysis(doc):
|
187 |
"""
|
|
|
116 |
return ' '.join(highlighted_text)
|
117 |
|
118 |
#################################################################################################
|
119 |
+
|
120 |
+
def generate_arc_diagram(doc, lang_code):
|
121 |
+
sentences = list(doc.sents)
|
122 |
+
arc_diagrams = []
|
123 |
+
for sent in sentences:
|
124 |
+
html = displacy.render(sent, style="dep", options={"distance": 100})
|
125 |
+
html = html.replace('height="375"', 'height="200"')
|
126 |
+
html = re.sub(r'<svg[^>]*>', lambda m: m.group(0).replace('height="450"', 'height="300"'), html)
|
127 |
+
html = re.sub(r'<g [^>]*transform="translate\((\d+),(\d+)\)"', lambda m: f'<g transform="translate({m.group(1)},50)"', html)
|
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.
|
135 |
|
136 |
Args:
|
137 |
doc: Documento procesado por spaCy
|
138 |
Returns:
|
139 |
list: Lista de diagramas en formato HTML
|
140 |
+
|
141 |
arc_diagrams = []
|
142 |
for sent in doc.sents:
|
143 |
words = [token.text for token in sent]
|
|
|
194 |
|
195 |
arc_diagrams.append(html)
|
196 |
return arc_diagrams
|
197 |
+
"""
|
198 |
+
|
199 |
|
200 |
+
|
201 |
#################################################################################################
|
202 |
def get_detailed_pos_analysis(doc):
|
203 |
"""
|