Update modules/ui.py
Browse files- modules/ui.py +12 -12
modules/ui.py
CHANGED
@@ -197,6 +197,7 @@ def display_student_progress(username, lang_code='es'):
|
|
197 |
st.info("Intenta realizar algunos an谩lisis de texto primero.")
|
198 |
|
199 |
##################################################################################################
|
|
|
200 |
def display_morphosyntax_analysis_interface(nlp_models, lang_code):
|
201 |
translations = {
|
202 |
'es': {
|
@@ -235,8 +236,9 @@ def display_morphosyntax_analysis_interface(nlp_models, lang_code):
|
|
235 |
|
236 |
input_key = f"morphosyntax_input_{lang_code}"
|
237 |
|
238 |
-
|
239 |
-
|
|
|
240 |
|
241 |
# Funci贸n para actualizar el estado del input
|
242 |
def update_input():
|
@@ -246,17 +248,15 @@ def display_morphosyntax_analysis_interface(nlp_models, lang_code):
|
|
246 |
t['input_label'],
|
247 |
height=150,
|
248 |
placeholder=t['input_placeholder'],
|
249 |
-
value=st.session_state
|
250 |
-
key=f"
|
251 |
on_change=update_input
|
252 |
)
|
253 |
-
st.session_state.input_text = sentence_input
|
254 |
|
255 |
if st.button(t['analyze_button'], key=f"analyze_button_{lang_code}"):
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
doc = nlp_models[lang_code](sentence_input)
|
260 |
|
261 |
word_colors = get_repeated_words_colors(doc)
|
262 |
|
@@ -267,8 +267,8 @@ def display_morphosyntax_analysis_interface(nlp_models, lang_code):
|
|
267 |
st.markdown(f"##### {t['legend']}")
|
268 |
legend_html = "<div style='display: flex; flex-wrap: wrap;'>"
|
269 |
for pos, color in POS_COLORS.items():
|
270 |
-
if pos in POS_TRANSLATIONS:
|
271 |
-
legend_html += f"<div style='margin-right: 10px;'><span style='background-color: {color}; padding: 2px 5px;'>{POS_TRANSLATIONS[pos]}</span></div>"
|
272 |
legend_html += "</div>"
|
273 |
st.markdown(legend_html, unsafe_allow_html=True)
|
274 |
|
@@ -286,7 +286,7 @@ def display_morphosyntax_analysis_interface(nlp_models, lang_code):
|
|
286 |
|
287 |
if store_morphosyntax_result(
|
288 |
st.session_state.username,
|
289 |
-
|
290 |
word_colors,
|
291 |
arc_diagrams,
|
292 |
):
|
|
|
197 |
st.info("Intenta realizar algunos an谩lisis de texto primero.")
|
198 |
|
199 |
##################################################################################################
|
200 |
+
|
201 |
def display_morphosyntax_analysis_interface(nlp_models, lang_code):
|
202 |
translations = {
|
203 |
'es': {
|
|
|
236 |
|
237 |
input_key = f"morphosyntax_input_{lang_code}"
|
238 |
|
239 |
+
# Inicializar la clave en session_state si no existe
|
240 |
+
if input_key not in st.session_state:
|
241 |
+
st.session_state[input_key] = ""
|
242 |
|
243 |
# Funci贸n para actualizar el estado del input
|
244 |
def update_input():
|
|
|
248 |
t['input_label'],
|
249 |
height=150,
|
250 |
placeholder=t['input_placeholder'],
|
251 |
+
value=st.session_state[input_key],
|
252 |
+
key=f"text_area_{lang_code}",
|
253 |
on_change=update_input
|
254 |
)
|
|
|
255 |
|
256 |
if st.button(t['analyze_button'], key=f"analyze_button_{lang_code}"):
|
257 |
+
current_input = st.session_state[input_key]
|
258 |
+
if current_input:
|
259 |
+
doc = nlp_models[lang_code](current_input)
|
|
|
260 |
|
261 |
word_colors = get_repeated_words_colors(doc)
|
262 |
|
|
|
267 |
st.markdown(f"##### {t['legend']}")
|
268 |
legend_html = "<div style='display: flex; flex-wrap: wrap;'>"
|
269 |
for pos, color in POS_COLORS.items():
|
270 |
+
if pos in POS_TRANSLATIONS[lang_code]:
|
271 |
+
legend_html += f"<div style='margin-right: 10px;'><span style='background-color: {color}; padding: 2px 5px;'>{POS_TRANSLATIONS[lang_code][pos]}</span></div>"
|
272 |
legend_html += "</div>"
|
273 |
st.markdown(legend_html, unsafe_allow_html=True)
|
274 |
|
|
|
286 |
|
287 |
if store_morphosyntax_result(
|
288 |
st.session_state.username,
|
289 |
+
current_input,
|
290 |
word_colors,
|
291 |
arc_diagrams,
|
292 |
):
|