Spaces:
Running
Running
Update modules/morphosyntax/morphosyntax_interface.py
Browse files
modules/morphosyntax/morphosyntax_interface.py
CHANGED
|
@@ -112,7 +112,7 @@ def display_morphosyntax_interface(lang_code, nlp_models, t):
|
|
| 112 |
|
| 113 |
############################################################################################################
|
| 114 |
def display_morphosyntax_results(result, lang_code, t):
|
| 115 |
-
|
| 116 |
Muestra los resultados del análisis morfosintáctico.
|
| 117 |
Args:
|
| 118 |
result: Resultado del análisis
|
|
@@ -123,14 +123,14 @@ def display_morphosyntax_results(result, lang_code, t):
|
|
| 123 |
morpho_t = t.get('MORPHOSYNTACTIC', {})
|
| 124 |
|
| 125 |
if result is None:
|
| 126 |
-
st.warning(
|
| 127 |
return
|
| 128 |
|
| 129 |
doc = result['doc']
|
| 130 |
advanced_analysis = result['advanced_analysis']
|
| 131 |
|
| 132 |
-
# Mostrar leyenda
|
| 133 |
-
st.markdown(f"##### {
|
| 134 |
legend_html = "<div style='display: flex; flex-wrap: wrap;'>"
|
| 135 |
for pos, color in POS_COLORS.items():
|
| 136 |
if pos in POS_TRANSLATIONS[lang_code]:
|
|
@@ -138,21 +138,21 @@ def display_morphosyntax_results(result, lang_code, t):
|
|
| 138 |
legend_html += "</div>"
|
| 139 |
st.markdown(legend_html, unsafe_allow_html=True)
|
| 140 |
|
| 141 |
-
# Mostrar análisis de palabras repetidas
|
| 142 |
word_colors = get_repeated_words_colors(doc)
|
| 143 |
-
with st.expander(
|
| 144 |
highlighted_text = highlight_repeated_words(doc, word_colors)
|
| 145 |
st.markdown(highlighted_text, unsafe_allow_html=True)
|
| 146 |
|
| 147 |
# Mostrar estructura de oraciones
|
| 148 |
-
with st.expander(
|
| 149 |
for i, sent_analysis in enumerate(advanced_analysis['sentence_structure']):
|
| 150 |
sentence_str = (
|
| 151 |
-
f"**{
|
| 152 |
-
f"{
|
| 153 |
-
f"{
|
| 154 |
-
f"{
|
| 155 |
-
f"{
|
| 156 |
)
|
| 157 |
st.markdown(sentence_str)
|
| 158 |
|
|
|
|
| 112 |
|
| 113 |
############################################################################################################
|
| 114 |
def display_morphosyntax_results(result, lang_code, t):
|
| 115 |
+
"""
|
| 116 |
Muestra los resultados del análisis morfosintáctico.
|
| 117 |
Args:
|
| 118 |
result: Resultado del análisis
|
|
|
|
| 123 |
morpho_t = t.get('MORPHOSYNTACTIC', {})
|
| 124 |
|
| 125 |
if result is None:
|
| 126 |
+
st.warning(t['no_results']) # Añade esta traducción a tu diccionario
|
| 127 |
return
|
| 128 |
|
| 129 |
doc = result['doc']
|
| 130 |
advanced_analysis = result['advanced_analysis']
|
| 131 |
|
| 132 |
+
# Mostrar leyenda (código existente)
|
| 133 |
+
st.markdown(f"##### {t['legend']}")
|
| 134 |
legend_html = "<div style='display: flex; flex-wrap: wrap;'>"
|
| 135 |
for pos, color in POS_COLORS.items():
|
| 136 |
if pos in POS_TRANSLATIONS[lang_code]:
|
|
|
|
| 138 |
legend_html += "</div>"
|
| 139 |
st.markdown(legend_html, unsafe_allow_html=True)
|
| 140 |
|
| 141 |
+
# Mostrar análisis de palabras repetidas (código existente)
|
| 142 |
word_colors = get_repeated_words_colors(doc)
|
| 143 |
+
with st.expander(t['repeated_words'], expanded=True):
|
| 144 |
highlighted_text = highlight_repeated_words(doc, word_colors)
|
| 145 |
st.markdown(highlighted_text, unsafe_allow_html=True)
|
| 146 |
|
| 147 |
# Mostrar estructura de oraciones
|
| 148 |
+
with st.expander(t['sentence_structure'], expanded=True):
|
| 149 |
for i, sent_analysis in enumerate(advanced_analysis['sentence_structure']):
|
| 150 |
sentence_str = (
|
| 151 |
+
f"**{t['sentence']} {i+1}** "
|
| 152 |
+
f"{t['root']}: {sent_analysis['root']} ({sent_analysis['root_pos']}) -- "
|
| 153 |
+
f"{t['subjects']}: {', '.join(sent_analysis['subjects'])} -- "
|
| 154 |
+
f"{t['objects']}: {', '.join(sent_analysis['objects'])} -- "
|
| 155 |
+
f"{t['verbs']}: {', '.join(sent_analysis['verbs'])}"
|
| 156 |
)
|
| 157 |
st.markdown(sentence_str)
|
| 158 |
|