Update app.py
Browse files
app.py
CHANGED
@@ -1,51 +1,54 @@
|
|
1 |
-
#app.py
|
2 |
import streamlit as st
|
3 |
from modules.database import initialize_mongodb_connection
|
4 |
from modules.auth import authenticate_user, get_user_role, register_user
|
5 |
-
from modules.ui import
|
|
|
|
|
|
|
|
|
|
|
6 |
from modules.spacy_utils import load_spacy_models
|
7 |
import time
|
8 |
|
9 |
st.set_page_config(page_title="AIdeaText", layout="wide", page_icon="random")
|
10 |
|
11 |
def logged_in_interface():
|
12 |
-
nlp_models
|
|
|
|
|
13 |
languages = {'Español': 'es', 'English': 'en', 'Français': 'fr'}
|
14 |
-
|
15 |
# Crear un contenedor para la barra superior
|
16 |
with st.container():
|
17 |
# Usar más columnas para un mejor control del espacio
|
18 |
col1, col2, col3, col4, col5 = st.columns([1, 1, 0.8, 1, 1])
|
19 |
-
|
20 |
with col1:
|
21 |
st.markdown(f"<h3 style='margin-bottom: 0;'>Bienvenido, {st.session_state.username}</h3>", unsafe_allow_html=True)
|
22 |
-
|
23 |
with col3:
|
24 |
-
st.markdown("<p style='font-size: 1.2rem; margin-bottom: 0; padding-top: 15px;'>Selecciona el idioma del texto que
|
25 |
-
|
26 |
with col4:
|
27 |
st.markdown("""
|
28 |
<style>
|
29 |
.stSelectbox { margin-left: -20px; }
|
30 |
div[data-testid="stSelectbox"] {
|
31 |
-
margin-top: 0px;
|
32 |
-
margin-bottom: 10px;
|
33 |
}
|
34 |
</style>
|
35 |
""", unsafe_allow_html=True)
|
36 |
selected_lang = st.selectbox("", list(languages.keys()), key="language_selector", label_visibility="collapsed")
|
37 |
lang_code = languages[selected_lang]
|
38 |
-
|
39 |
with col5:
|
40 |
st.markdown("""
|
41 |
<style>
|
42 |
div[data-testid="stButton"] {
|
43 |
-
margin-top: 0px;
|
44 |
margin-bottom: 10px;
|
45 |
}
|
46 |
div[data-testid="stButton"] > button {
|
47 |
width: 100%;
|
48 |
-
padding: 8px 10px;
|
49 |
font-size: 1rem;
|
50 |
}
|
51 |
</style>
|
@@ -54,31 +57,26 @@ def logged_in_interface():
|
|
54 |
st.session_state.logged_in = False
|
55 |
st.experimental_rerun()
|
56 |
|
57 |
-
##############################################################Añadir una línea divisoria#########################################################
|
58 |
st.markdown("---")
|
59 |
-
|
60 |
tab1, tab2, tab3, tab4 = st.tabs(["Análisis morfosintáctico", "Análisis semántico", "Análisis semántico discursivo", "Mi Progreso"])
|
61 |
-
|
62 |
with tab1:
|
63 |
-
|
64 |
-
|
65 |
with tab2:
|
66 |
-
display_semantic_analysis_interface(nlp_models, lang_code)
|
67 |
-
|
68 |
with tab3:
|
69 |
st.header("Análisis semántico discursivo")
|
70 |
st.write("Esta función aún no está implementada.")
|
71 |
-
|
72 |
with tab4:
|
73 |
display_student_progress(st.session_state.username, lang_code)
|
74 |
|
75 |
def main():
|
76 |
if not initialize_mongodb_connection():
|
77 |
st.warning("La conexión a la base de datos MongoDB no está disponible. Algunas funciones pueden no estar operativas.")
|
78 |
-
|
79 |
if 'logged_in' not in st.session_state:
|
80 |
st.session_state.logged_in = False
|
81 |
-
|
82 |
if not st.session_state.logged_in:
|
83 |
login_register_page()
|
84 |
else:
|
|
|
1 |
+
# app.py
|
2 |
import streamlit as st
|
3 |
from modules.database import initialize_mongodb_connection
|
4 |
from modules.auth import authenticate_user, get_user_role, register_user
|
5 |
+
from modules.ui import (
|
6 |
+
login_register_page,
|
7 |
+
display_student_progress,
|
8 |
+
display_morphosyntax_analysis_interface,
|
9 |
+
display_semantic_analysis_interface
|
10 |
+
)
|
11 |
from modules.spacy_utils import load_spacy_models
|
12 |
import time
|
13 |
|
14 |
st.set_page_config(page_title="AIdeaText", layout="wide", page_icon="random")
|
15 |
|
16 |
def logged_in_interface():
|
17 |
+
if 'nlp_models' not in st.session_state:
|
18 |
+
st.session_state.nlp_models = load_spacy_models()
|
19 |
+
|
20 |
languages = {'Español': 'es', 'English': 'en', 'Français': 'fr'}
|
21 |
+
|
22 |
# Crear un contenedor para la barra superior
|
23 |
with st.container():
|
24 |
# Usar más columnas para un mejor control del espacio
|
25 |
col1, col2, col3, col4, col5 = st.columns([1, 1, 0.8, 1, 1])
|
|
|
26 |
with col1:
|
27 |
st.markdown(f"<h3 style='margin-bottom: 0;'>Bienvenido, {st.session_state.username}</h3>", unsafe_allow_html=True)
|
|
|
28 |
with col3:
|
29 |
+
st.markdown("<p style='font-size: 1.2rem; margin-bottom: 0; padding-top: 15px;'>Selecciona el idioma del texto que analizarás</p>", unsafe_allow_html=True)
|
|
|
30 |
with col4:
|
31 |
st.markdown("""
|
32 |
<style>
|
33 |
.stSelectbox { margin-left: -20px; }
|
34 |
div[data-testid="stSelectbox"] {
|
35 |
+
margin-top: 0px;
|
36 |
+
margin-bottom: 10px;
|
37 |
}
|
38 |
</style>
|
39 |
""", unsafe_allow_html=True)
|
40 |
selected_lang = st.selectbox("", list(languages.keys()), key="language_selector", label_visibility="collapsed")
|
41 |
lang_code = languages[selected_lang]
|
|
|
42 |
with col5:
|
43 |
st.markdown("""
|
44 |
<style>
|
45 |
div[data-testid="stButton"] {
|
46 |
+
margin-top: 0px;
|
47 |
margin-bottom: 10px;
|
48 |
}
|
49 |
div[data-testid="stButton"] > button {
|
50 |
width: 100%;
|
51 |
+
padding: 8px 10px;
|
52 |
font-size: 1rem;
|
53 |
}
|
54 |
</style>
|
|
|
57 |
st.session_state.logged_in = False
|
58 |
st.experimental_rerun()
|
59 |
|
|
|
60 |
st.markdown("---")
|
|
|
61 |
tab1, tab2, tab3, tab4 = st.tabs(["Análisis morfosintáctico", "Análisis semántico", "Análisis semántico discursivo", "Mi Progreso"])
|
62 |
+
|
63 |
with tab1:
|
64 |
+
display_morphosyntax_analysis_interface(st.session_state.nlp_models, lang_code)
|
|
|
65 |
with tab2:
|
66 |
+
display_semantic_analysis_interface(st.session_state.nlp_models, lang_code)
|
|
|
67 |
with tab3:
|
68 |
st.header("Análisis semántico discursivo")
|
69 |
st.write("Esta función aún no está implementada.")
|
|
|
70 |
with tab4:
|
71 |
display_student_progress(st.session_state.username, lang_code)
|
72 |
|
73 |
def main():
|
74 |
if not initialize_mongodb_connection():
|
75 |
st.warning("La conexión a la base de datos MongoDB no está disponible. Algunas funciones pueden no estar operativas.")
|
76 |
+
|
77 |
if 'logged_in' not in st.session_state:
|
78 |
st.session_state.logged_in = False
|
79 |
+
|
80 |
if not st.session_state.logged_in:
|
81 |
login_register_page()
|
82 |
else:
|