Update modules/morphosyntax/morphosyntax_interface.py
Browse files
modules/morphosyntax/morphosyntax_interface.py
CHANGED
@@ -23,38 +23,41 @@ def display_morphosyntax_interface(lang_code, nlp_models, t):
|
|
23 |
nlp_models: Modelos de spaCy cargados
|
24 |
t: Diccionario de traducciones
|
25 |
"""
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
input_key = f"morphosyntax_input_{lang_code}"
|
29 |
if input_key not in st.session_state:
|
30 |
st.session_state[input_key] = ""
|
31 |
|
32 |
sentence_input = st.text_area(
|
33 |
-
|
34 |
height=150,
|
35 |
-
placeholder=
|
36 |
value=st.session_state[input_key],
|
37 |
key=f"text_area_{lang_code}",
|
38 |
on_change=lambda: setattr(st.session_state, input_key, st.session_state[f"text_area_{lang_code}"])
|
39 |
)
|
40 |
|
41 |
-
if st.button(
|
42 |
current_input = st.session_state[input_key]
|
43 |
if current_input:
|
44 |
doc = nlp_models[lang_code](current_input)
|
45 |
-
|
46 |
# An谩lisis morfosint谩ctico avanzado
|
47 |
-
advanced_analysis = perform_advanced_morphosyntactic_analysis(current_input, nlp_models[lang_code])
|
48 |
-
|
49 |
# Guardar el resultado en el estado de la sesi贸n
|
50 |
st.session_state.morphosyntax_result = {
|
51 |
'doc': doc,
|
52 |
'advanced_analysis': advanced_analysis
|
53 |
}
|
54 |
-
|
55 |
# Mostrar resultados
|
56 |
-
display_morphosyntax_results(st.session_state.morphosyntax_result, lang_code,
|
57 |
-
|
58 |
# Guardar resultados
|
59 |
if store_morphosyntax_result(
|
60 |
st.session_state.username,
|
@@ -65,16 +68,17 @@ def display_morphosyntax_interface(lang_code, nlp_models, t):
|
|
65 |
advanced_analysis['morphological_analysis'],
|
66 |
advanced_analysis['sentence_structure']
|
67 |
):
|
68 |
-
st.success(
|
69 |
else:
|
70 |
-
st.error(
|
71 |
else:
|
72 |
-
st.warning(
|
|
|
73 |
elif 'morphosyntax_result' in st.session_state and st.session_state.morphosyntax_result is not None:
|
74 |
# Si hay un resultado guardado, mostrarlo
|
75 |
-
display_morphosyntax_results(st.session_state.morphosyntax_result, lang_code,
|
76 |
else:
|
77 |
-
st.info(
|
78 |
|
79 |
|
80 |
'''
|
|
|
23 |
nlp_models: Modelos de spaCy cargados
|
24 |
t: Diccionario de traducciones
|
25 |
"""
|
26 |
+
# Asegurarnos de que estamos accediendo al diccionario MORPHOSYNTACTIC
|
27 |
+
morpho_t = t.get('MORPHOSYNTACTIC', {})
|
28 |
+
|
29 |
+
st.title(morpho_t.get('title', 'AIdeaText - Morphological and Syntactic Analysis'))
|
30 |
|
31 |
input_key = f"morphosyntax_input_{lang_code}"
|
32 |
if input_key not in st.session_state:
|
33 |
st.session_state[input_key] = ""
|
34 |
|
35 |
sentence_input = st.text_area(
|
36 |
+
morpho_t.get('morpho_input_label', 'Enter text to analyze:'),
|
37 |
height=150,
|
38 |
+
placeholder=morpho_t.get('morpho_input_placeholder', 'Enter your text here...'),
|
39 |
value=st.session_state[input_key],
|
40 |
key=f"text_area_{lang_code}",
|
41 |
on_change=lambda: setattr(st.session_state, input_key, st.session_state[f"text_area_{lang_code}"])
|
42 |
)
|
43 |
|
44 |
+
if st.button(morpho_t.get('analyze_button', 'Analyze'), key=f"analyze_button_{lang_code}"):
|
45 |
current_input = st.session_state[input_key]
|
46 |
if current_input:
|
47 |
doc = nlp_models[lang_code](current_input)
|
48 |
+
|
49 |
# An谩lisis morfosint谩ctico avanzado
|
50 |
+
advanced_analysis = perform_advanced_morphosyntactic_analysis(current_input, nlp_models[lang_code])
|
51 |
+
|
52 |
# Guardar el resultado en el estado de la sesi贸n
|
53 |
st.session_state.morphosyntax_result = {
|
54 |
'doc': doc,
|
55 |
'advanced_analysis': advanced_analysis
|
56 |
}
|
57 |
+
|
58 |
# Mostrar resultados
|
59 |
+
display_morphosyntax_results(st.session_state.morphosyntax_result, lang_code, morpho_t)
|
60 |
+
|
61 |
# Guardar resultados
|
62 |
if store_morphosyntax_result(
|
63 |
st.session_state.username,
|
|
|
68 |
advanced_analysis['morphological_analysis'],
|
69 |
advanced_analysis['sentence_structure']
|
70 |
):
|
71 |
+
st.success(morpho_t.get('success_message', 'Analysis saved successfully.'))
|
72 |
else:
|
73 |
+
st.error(morpho_t.get('error_message', 'Error saving analysis.'))
|
74 |
else:
|
75 |
+
st.warning(morpho_t.get('warning_message', 'Please enter a text to analyze.'))
|
76 |
+
|
77 |
elif 'morphosyntax_result' in st.session_state and st.session_state.morphosyntax_result is not None:
|
78 |
# Si hay un resultado guardado, mostrarlo
|
79 |
+
display_morphosyntax_results(st.session_state.morphosyntax_result, lang_code, morpho_t)
|
80 |
else:
|
81 |
+
st.info(morpho_t.get('morpho_initial_message', 'Enter text to begin analysis.'))
|
82 |
|
83 |
|
84 |
'''
|