Spaces:
Sleeping
Sleeping
Update modules/morphosyntax/morphosyntax_interface.py
Browse files
modules/morphosyntax/morphosyntax_interface.py
CHANGED
|
@@ -109,6 +109,8 @@ def display_morphosyntax_interface(lang_code, nlp_models, t):
|
|
| 109 |
else:
|
| 110 |
st.info(morpho_t.get('morpho_initial_message', 'Enter text to begin analysis'))
|
| 111 |
|
|
|
|
|
|
|
| 112 |
def display_morphosyntax_results(result, lang_code, t):
|
| 113 |
"""
|
| 114 |
Muestra los resultados del an谩lisis morfosint谩ctico.
|
|
@@ -123,13 +125,12 @@ def display_morphosyntax_results(result, lang_code, t):
|
|
| 123 |
if result is None:
|
| 124 |
st.warning(morpho_t.get('no_results', 'No results available'))
|
| 125 |
return
|
| 126 |
-
|
| 127 |
|
| 128 |
doc = result['doc']
|
| 129 |
advanced_analysis = result['advanced_analysis']
|
| 130 |
|
| 131 |
-
# Mostrar leyenda
|
| 132 |
-
st.markdown(f"##### {
|
| 133 |
legend_html = "<div style='display: flex; flex-wrap: wrap;'>"
|
| 134 |
for pos, color in POS_COLORS.items():
|
| 135 |
if pos in POS_TRANSLATIONS[lang_code]:
|
|
@@ -137,21 +138,21 @@ def display_morphosyntax_results(result, lang_code, t):
|
|
| 137 |
legend_html += "</div>"
|
| 138 |
st.markdown(legend_html, unsafe_allow_html=True)
|
| 139 |
|
| 140 |
-
# Mostrar an谩lisis de palabras repetidas
|
| 141 |
word_colors = get_repeated_words_colors(doc)
|
| 142 |
-
with st.expander(
|
| 143 |
highlighted_text = highlight_repeated_words(doc, word_colors)
|
| 144 |
st.markdown(highlighted_text, unsafe_allow_html=True)
|
| 145 |
|
| 146 |
# Mostrar estructura de oraciones
|
| 147 |
-
with st.expander(
|
| 148 |
for i, sent_analysis in enumerate(advanced_analysis['sentence_structure']):
|
| 149 |
sentence_str = (
|
| 150 |
-
f"**{
|
| 151 |
-
f"{
|
| 152 |
-
f"{
|
| 153 |
-
f"{
|
| 154 |
-
f"{
|
| 155 |
)
|
| 156 |
st.markdown(sentence_str)
|
| 157 |
|
|
|
|
| 109 |
else:
|
| 110 |
st.info(morpho_t.get('morpho_initial_message', 'Enter text to begin analysis'))
|
| 111 |
|
| 112 |
+
|
| 113 |
+
############################################################################################################
|
| 114 |
def display_morphosyntax_results(result, lang_code, t):
|
| 115 |
"""
|
| 116 |
Muestra los resultados del an谩lisis morfosint谩ctico.
|
|
|
|
| 125 |
if result is None:
|
| 126 |
st.warning(morpho_t.get('no_results', 'No results available'))
|
| 127 |
return
|
|
|
|
| 128 |
|
| 129 |
doc = result['doc']
|
| 130 |
advanced_analysis = result['advanced_analysis']
|
| 131 |
|
| 132 |
+
# Mostrar leyenda
|
| 133 |
+
st.markdown(f"##### {morpho_t.get('legend', 'Legend: Grammatical categories')}")
|
| 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
|
| 142 |
word_colors = get_repeated_words_colors(doc)
|
| 143 |
+
with st.expander(morpho_t.get('repeated_words', '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(morpho_t.get('sentence_structure', 'Sentence structure'), expanded=True):
|
| 149 |
for i, sent_analysis in enumerate(advanced_analysis['sentence_structure']):
|
| 150 |
sentence_str = (
|
| 151 |
+
f"**{morpho_t.get('sentence', 'Sentence')} {i+1}** "
|
| 152 |
+
f"{morpho_t.get('root', 'Root')}: {sent_analysis['root']} ({sent_analysis['root_pos']}) -- "
|
| 153 |
+
f"{morpho_t.get('subjects', 'Subjects')}: {', '.join(sent_analysis['subjects'])} -- "
|
| 154 |
+
f"{morpho_t.get('objects', 'Objects')}: {', '.join(sent_analysis['objects'])} -- "
|
| 155 |
+
f"{morpho_t.get('verbs', 'Verbs')}: {', '.join(sent_analysis['verbs'])}"
|
| 156 |
)
|
| 157 |
st.markdown(sentence_str)
|
| 158 |
|