Spaces:
Running
Running
Update modules/morphosyntax/morphosyntax_interface.py
Browse files
modules/morphosyntax/morphosyntax_interface.py
CHANGED
|
@@ -25,7 +25,7 @@ from .morphosyntax_process import (
|
|
| 25 |
|
| 26 |
from ..utils.widget_utils import generate_unique_key
|
| 27 |
|
| 28 |
-
from ..database.morphosintax_mongo_db import store_student_morphosyntax_result
|
| 29 |
|
| 30 |
from ..database.morphosyntax_iterative_mongo_db import (
|
| 31 |
store_student_morphosyntax_base,
|
|
@@ -84,6 +84,30 @@ def display_iteration_analysis(container, analysis, lang_code, morpho_t):
|
|
| 84 |
st.subheader("An谩lisis de Cambios")
|
| 85 |
display_morphosyntax_results(analysis, lang_code, morpho_t)
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
############################################################################
|
| 88 |
|
| 89 |
def cache_analysis_results(key, result):
|
|
@@ -257,31 +281,7 @@ def display_morphosyntax_interface(lang_code, nlp_models, morpho_t):
|
|
| 257 |
logger.error(f"Error general en la interfaz: {str(e)}")
|
| 258 |
|
| 259 |
############################################################################
|
| 260 |
-
def display_arc_diagram(doc, analysis):
|
| 261 |
-
"""Muestra un diagrama de arco sin t铆tulo"""
|
| 262 |
-
try:
|
| 263 |
-
for sent in doc.sents:
|
| 264 |
-
html = displacy.render(sent, style="dep", options={
|
| 265 |
-
"distance": 100,
|
| 266 |
-
"arrow_spacing": 20,
|
| 267 |
-
"word_spacing": 30
|
| 268 |
-
})
|
| 269 |
-
|
| 270 |
-
# Ajustar tama帽o y posici贸n
|
| 271 |
-
html = html.replace('height="375"', 'height="200"')
|
| 272 |
-
html = re.sub(r'<svg[^>]*>', lambda m: m.group(0).replace('height="450"', 'height="300"'), html)
|
| 273 |
-
html = re.sub(r'<g [^>]*transform="translate\((\d+),(\d+)\)"',
|
| 274 |
-
lambda m: f'<g transform="translate({m.group(1)},50)"', html)
|
| 275 |
-
|
| 276 |
-
# Envolver en contenedor con estilo
|
| 277 |
-
html = f'<div class="arc-diagram-container">{html}</div>'
|
| 278 |
-
|
| 279 |
-
st.write(html, unsafe_allow_html=True)
|
| 280 |
-
|
| 281 |
-
except Exception as e:
|
| 282 |
-
logger.error(f"Error en display_arc_diagram: {str(e)}")
|
| 283 |
|
| 284 |
-
####################
|
| 285 |
|
| 286 |
def display_morphosyntax_results(result, lang_code, morpho_t):
|
| 287 |
"""
|
|
|
|
| 25 |
|
| 26 |
from ..utils.widget_utils import generate_unique_key
|
| 27 |
|
| 28 |
+
# from ..database.morphosintax_mongo_db import store_student_morphosyntax_result
|
| 29 |
|
| 30 |
from ..database.morphosyntax_iterative_mongo_db import (
|
| 31 |
store_student_morphosyntax_base,
|
|
|
|
| 84 |
st.subheader("An谩lisis de Cambios")
|
| 85 |
display_morphosyntax_results(analysis, lang_code, morpho_t)
|
| 86 |
|
| 87 |
+
def display_arc_diagram(doc, analysis):
|
| 88 |
+
"""Muestra un diagrama de arco sin t铆tulo"""
|
| 89 |
+
try:
|
| 90 |
+
for sent in doc.sents:
|
| 91 |
+
html = displacy.render(sent, style="dep", options={
|
| 92 |
+
"distance": 100,
|
| 93 |
+
"arrow_spacing": 20,
|
| 94 |
+
"word_spacing": 30
|
| 95 |
+
})
|
| 96 |
+
|
| 97 |
+
# Ajustar tama帽o y posici贸n
|
| 98 |
+
html = html.replace('height="375"', 'height="200"')
|
| 99 |
+
html = re.sub(r'<svg[^>]*>', lambda m: m.group(0).replace('height="450"', 'height="300"'), html)
|
| 100 |
+
html = re.sub(r'<g [^>]*transform="translate\((\d+),(\d+)\)"',
|
| 101 |
+
lambda m: f'<g transform="translate({m.group(1)},50)"', html)
|
| 102 |
+
|
| 103 |
+
# Envolver en contenedor con estilo
|
| 104 |
+
html = f'<div class="arc-diagram-container">{html}</div>'
|
| 105 |
+
|
| 106 |
+
st.write(html, unsafe_allow_html=True)
|
| 107 |
+
|
| 108 |
+
except Exception as e:
|
| 109 |
+
logger.error(f"Error en display_arc_diagram: {str(e)}")
|
| 110 |
+
|
| 111 |
############################################################################
|
| 112 |
|
| 113 |
def cache_analysis_results(key, result):
|
|
|
|
| 281 |
logger.error(f"Error general en la interfaz: {str(e)}")
|
| 282 |
|
| 283 |
############################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
|
|
|
|
| 285 |
|
| 286 |
def display_morphosyntax_results(result, lang_code, morpho_t):
|
| 287 |
"""
|