Update modules/morphosyntax/morphosyntax_interface.py
Browse files
modules/morphosyntax/morphosyntax_interface.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
#modules/morphosyntax/morphosyntax_interface.py
|
2 |
import streamlit as st
|
|
|
3 |
from streamlit_float import *
|
4 |
from streamlit_antd_components import *
|
5 |
from streamlit.components.v1 import html
|
@@ -20,52 +21,61 @@ def display_morphosyntax_interface(lang_code, nlp_models, t):
|
|
20 |
Interfaz para el an谩lisis morfosint谩ctico
|
21 |
"""
|
22 |
morpho_t = t.get('MORPHOSYNTACTIC', {})
|
23 |
-
st.title(morpho_t.get('title', 'AIdeaText - Morphological Analysis'))
|
24 |
|
25 |
input_key = f"morphosyntax_input_{lang_code}"
|
|
|
26 |
if input_key not in st.session_state:
|
27 |
st.session_state[input_key] = ""
|
28 |
|
29 |
sentence_input = st.text_area(
|
30 |
-
|
31 |
height=150,
|
32 |
-
placeholder=
|
33 |
value=st.session_state[input_key],
|
34 |
-
key=f"text_area_{lang_code}"
|
|
|
35 |
)
|
36 |
|
37 |
-
if st.button(
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
st.
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
else:
|
66 |
-
st.error(
|
67 |
else:
|
68 |
-
st.warning(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
# Bot贸n de exportaci贸n
|
71 |
if st.button(morpho_t.get('export_button', 'Export Analysis')):
|
|
|
1 |
#modules/morphosyntax/morphosyntax_interface.py
|
2 |
import streamlit as st
|
3 |
+
import spacy_streamlit
|
4 |
from streamlit_float import *
|
5 |
from streamlit_antd_components import *
|
6 |
from streamlit.components.v1 import html
|
|
|
21 |
Interfaz para el an谩lisis morfosint谩ctico
|
22 |
"""
|
23 |
morpho_t = t.get('MORPHOSYNTACTIC', {})
|
24 |
+
#st.title(morpho_t.get('title', 'AIdeaText - Morphological Analysis'))
|
25 |
|
26 |
input_key = f"morphosyntax_input_{lang_code}"
|
27 |
+
|
28 |
if input_key not in st.session_state:
|
29 |
st.session_state[input_key] = ""
|
30 |
|
31 |
sentence_input = st.text_area(
|
32 |
+
t['input_label'],
|
33 |
height=150,
|
34 |
+
placeholder=t['input_placeholder'],
|
35 |
value=st.session_state[input_key],
|
36 |
+
key=f"text_area_{lang_code}",
|
37 |
+
on_change=lambda: setattr(st.session_state, input_key, st.session_state[f"text_area_{lang_code}"])
|
38 |
)
|
39 |
|
40 |
+
if st.button(t['analyze_button'], key=f"analyze_button_{lang_code}"):
|
41 |
+
current_input = st.session_state[input_key]
|
42 |
+
if current_input:
|
43 |
+
doc = nlp_models[lang_code](current_input)
|
44 |
+
|
45 |
+
# An谩lisis morfosint谩ctico avanzado
|
46 |
+
advanced_analysis = perform_advanced_morphosyntactic_analysis(current_input, nlp_models[lang_code])
|
47 |
+
|
48 |
+
# Guardar el resultado en el estado de la sesi贸n
|
49 |
+
st.session_state.morphosyntax_result = {
|
50 |
+
'doc': doc,
|
51 |
+
'advanced_analysis': advanced_analysis
|
52 |
+
}
|
53 |
+
|
54 |
+
# Mostrar resultados
|
55 |
+
display_morphosyntax_results(st.session_state.morphosyntax_result, lang_code, t)
|
56 |
+
|
57 |
+
# Guardar resultados
|
58 |
+
if store_morphosyntax_result(
|
59 |
+
st.session_state.username,
|
60 |
+
current_input,
|
61 |
+
get_repeated_words_colors(doc),
|
62 |
+
advanced_analysis['arc_diagram'],
|
63 |
+
advanced_analysis['pos_analysis'],
|
64 |
+
advanced_analysis['morphological_analysis'],
|
65 |
+
advanced_analysis['sentence_structure']
|
66 |
+
):
|
67 |
+
st.success(t['success_message'])
|
68 |
else:
|
69 |
+
st.error(t['error_message'])
|
70 |
else:
|
71 |
+
st.warning(t['warning_message'])
|
72 |
+
elif 'morphosyntax_result' in st.session_state and st.session_state.morphosyntax_result is not None:
|
73 |
+
|
74 |
+
# Si hay un resultado guardado, mostrarlo
|
75 |
+
display_morphosyntax_results(st.session_state.morphosyntax_result, lang_code, t)
|
76 |
+
else:
|
77 |
+
st.info(t['initial_message']) # A帽ade esta traducci贸n a tu diccionario
|
78 |
+
|
79 |
|
80 |
# Bot贸n de exportaci贸n
|
81 |
if st.button(morpho_t.get('export_button', 'Export Analysis')):
|