AIdeaText commited on
Commit
0eb172c
·
verified ·
1 Parent(s): f90de2b

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(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,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(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
 
 
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