Spaces:
Running
Running
Update modules/morphosyntax/morphosyntax_interface.py
Browse files
modules/morphosyntax/morphosyntax_interface.py
CHANGED
|
@@ -14,8 +14,16 @@ from ..database.morphosintaxis_export import export_user_interactions
|
|
| 14 |
import logging
|
| 15 |
logger = logging.getLogger(__name__)
|
| 16 |
|
| 17 |
-
def display_morphosyntax_interface(lang_code, nlp_models, t):
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
input_key = f"morphosyntax_input_{lang_code}"
|
| 21 |
|
|
@@ -23,15 +31,15 @@ def display_morphosyntax_interface(lang_code, nlp_models, t):
|
|
| 23 |
st.session_state[input_key] = ""
|
| 24 |
|
| 25 |
sentence_input = st.text_area(
|
| 26 |
-
t['
|
| 27 |
height=150,
|
| 28 |
-
placeholder=t['
|
| 29 |
value=st.session_state[input_key],
|
| 30 |
key=f"text_area_{lang_code}",
|
| 31 |
on_change=lambda: setattr(st.session_state, input_key, st.session_state[f"text_area_{lang_code}"])
|
| 32 |
)
|
| 33 |
|
| 34 |
-
if st.button(t['
|
| 35 |
current_input = st.session_state[input_key]
|
| 36 |
if current_input:
|
| 37 |
doc = nlp_models[lang_code](current_input)
|
|
@@ -58,18 +66,16 @@ def display_morphosyntax_interface(lang_code, nlp_models, t):
|
|
| 58 |
advanced_analysis['morphological_analysis'],
|
| 59 |
advanced_analysis['sentence_structure']
|
| 60 |
):
|
| 61 |
-
st.success(t['
|
| 62 |
else:
|
| 63 |
-
st.error(t['
|
| 64 |
else:
|
| 65 |
-
st.warning(t['
|
| 66 |
elif 'morphosyntax_result' in st.session_state and st.session_state.morphosyntax_result is not None:
|
| 67 |
-
|
| 68 |
# Si hay un resultado guardado, mostrarlo
|
| 69 |
display_morphosyntax_results(st.session_state.morphosyntax_result, lang_code, t)
|
| 70 |
else:
|
| 71 |
-
st.info(t['
|
| 72 |
-
|
| 73 |
|
| 74 |
|
| 75 |
'''
|
|
|
|
| 14 |
import logging
|
| 15 |
logger = logging.getLogger(__name__)
|
| 16 |
|
|
|
|
| 17 |
|
| 18 |
+
def display_morphosyntax_analysis_interface(lang_code, nlp_models, t):
|
| 19 |
+
"""
|
| 20 |
+
Interfaz para el an谩lisis morfosint谩ctico
|
| 21 |
+
Args:
|
| 22 |
+
lang_code: C贸digo del idioma actual
|
| 23 |
+
nlp_models: Modelos de spaCy cargados
|
| 24 |
+
t: Diccionario de traducciones
|
| 25 |
+
"""
|
| 26 |
+
st.title(t['morphosyntax_title'])
|
| 27 |
|
| 28 |
input_key = f"morphosyntax_input_{lang_code}"
|
| 29 |
|
|
|
|
| 31 |
st.session_state[input_key] = ""
|
| 32 |
|
| 33 |
sentence_input = st.text_area(
|
| 34 |
+
t['morphosyntax_input_label'],
|
| 35 |
height=150,
|
| 36 |
+
placeholder=t['morphosyntax_placeholder'],
|
| 37 |
value=st.session_state[input_key],
|
| 38 |
key=f"text_area_{lang_code}",
|
| 39 |
on_change=lambda: setattr(st.session_state, input_key, st.session_state[f"text_area_{lang_code}"])
|
| 40 |
)
|
| 41 |
|
| 42 |
+
if st.button(t['morphosyntax_analyze_button'], key=f"analyze_button_{lang_code}"):
|
| 43 |
current_input = st.session_state[input_key]
|
| 44 |
if current_input:
|
| 45 |
doc = nlp_models[lang_code](current_input)
|
|
|
|
| 66 |
advanced_analysis['morphological_analysis'],
|
| 67 |
advanced_analysis['sentence_structure']
|
| 68 |
):
|
| 69 |
+
st.success(t['morphosyntax_success_message'])
|
| 70 |
else:
|
| 71 |
+
st.error(t['morphosyntax_error_message'])
|
| 72 |
else:
|
| 73 |
+
st.warning(t['morphosyntax_warning_message'])
|
| 74 |
elif 'morphosyntax_result' in st.session_state and st.session_state.morphosyntax_result is not None:
|
|
|
|
| 75 |
# Si hay un resultado guardado, mostrarlo
|
| 76 |
display_morphosyntax_results(st.session_state.morphosyntax_result, lang_code, t)
|
| 77 |
else:
|
| 78 |
+
st.info(t['morphosyntax_initial_message'])
|
|
|
|
| 79 |
|
| 80 |
|
| 81 |
'''
|