Update app.py
Browse files
app.py
CHANGED
|
@@ -4,21 +4,22 @@ 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 |
display_discourse_analysis_interface
|
| 11 |
)
|
| 12 |
-
from modules.discourse_analysis import perform_discourse_analysis
|
| 13 |
from modules.spacy_utils import load_spacy_models
|
| 14 |
-
import time
|
| 15 |
|
| 16 |
st.set_page_config(page_title="AIdeaText", layout="wide", page_icon="random")
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
def logged_in_interface():
|
| 19 |
-
if 'nlp_models' not in st.session_state:
|
| 20 |
-
st.session_state.nlp_models = load_spacy_models()
|
| 21 |
-
|
| 22 |
languages = {'Español': 'es', 'English': 'en', 'Français': 'fr'}
|
| 23 |
|
| 24 |
# Crear un contenedor para la barra superior
|
|
@@ -30,42 +31,22 @@ def logged_in_interface():
|
|
| 30 |
with col3:
|
| 31 |
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)
|
| 32 |
with col4:
|
| 33 |
-
st.markdown("""
|
| 34 |
-
<style>
|
| 35 |
-
.stSelectbox { margin-left: -20px; }
|
| 36 |
-
div[data-testid="stSelectbox"] {
|
| 37 |
-
margin-top: 0px;
|
| 38 |
-
margin-bottom: 10px;
|
| 39 |
-
}
|
| 40 |
-
</style>
|
| 41 |
-
""", unsafe_allow_html=True)
|
| 42 |
selected_lang = st.selectbox("", list(languages.keys()), key="language_selector", label_visibility="collapsed")
|
| 43 |
lang_code = languages[selected_lang]
|
| 44 |
with col5:
|
| 45 |
-
st.markdown("""
|
| 46 |
-
<style>
|
| 47 |
-
div[data-testid="stButton"] {
|
| 48 |
-
margin-top: 0px;
|
| 49 |
-
margin-bottom: 10px;
|
| 50 |
-
}
|
| 51 |
-
div[data-testid="stButton"] > button {
|
| 52 |
-
width: 100%;
|
| 53 |
-
padding: 8px 10px;
|
| 54 |
-
font-size: 1rem;
|
| 55 |
-
}
|
| 56 |
-
</style>
|
| 57 |
-
""", unsafe_allow_html=True)
|
| 58 |
if st.button("Cerrar Sesión", key="logout_button"):
|
| 59 |
st.session_state.logged_in = False
|
| 60 |
st.experimental_rerun()
|
| 61 |
|
|
|
|
| 62 |
st.markdown("---")
|
| 63 |
-
|
| 64 |
-
|
|
|
|
| 65 |
with tab1:
|
| 66 |
-
display_morphosyntax_analysis_interface(
|
| 67 |
with tab2:
|
| 68 |
-
display_semantic_analysis_interface(
|
| 69 |
with tab3:
|
| 70 |
display_discourse_analysis_interface(nlp_models, lang_code)
|
| 71 |
with tab4:
|
|
@@ -74,10 +55,10 @@ def logged_in_interface():
|
|
| 74 |
def main():
|
| 75 |
if not initialize_mongodb_connection():
|
| 76 |
st.warning("La conexión a la base de datos MongoDB no está disponible. Algunas funciones pueden no estar operativas.")
|
| 77 |
-
|
| 78 |
if 'logged_in' not in st.session_state:
|
| 79 |
st.session_state.logged_in = False
|
| 80 |
-
|
| 81 |
if not st.session_state.logged_in:
|
| 82 |
login_register_page()
|
| 83 |
else:
|
|
|
|
| 4 |
from modules.auth import authenticate_user, get_user_role, register_user
|
| 5 |
from modules.ui import (
|
| 6 |
login_register_page,
|
|
|
|
| 7 |
display_morphosyntax_analysis_interface,
|
| 8 |
+
display_semantic_analysis_interface,
|
| 9 |
display_discourse_analysis_interface
|
| 10 |
)
|
|
|
|
| 11 |
from modules.spacy_utils import load_spacy_models
|
|
|
|
| 12 |
|
| 13 |
st.set_page_config(page_title="AIdeaText", layout="wide", page_icon="random")
|
| 14 |
|
| 15 |
+
# Cargar los modelos de spaCy una vez al inicio de la aplicación
|
| 16 |
+
@st.cache_resource
|
| 17 |
+
def load_models():
|
| 18 |
+
return load_spacy_models()
|
| 19 |
+
|
| 20 |
+
nlp_models = load_models()
|
| 21 |
+
|
| 22 |
def logged_in_interface():
|
|
|
|
|
|
|
|
|
|
| 23 |
languages = {'Español': 'es', 'English': 'en', 'Français': 'fr'}
|
| 24 |
|
| 25 |
# Crear un contenedor para la barra superior
|
|
|
|
| 31 |
with col3:
|
| 32 |
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)
|
| 33 |
with col4:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
selected_lang = st.selectbox("", list(languages.keys()), key="language_selector", label_visibility="collapsed")
|
| 35 |
lang_code = languages[selected_lang]
|
| 36 |
with col5:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
if st.button("Cerrar Sesión", key="logout_button"):
|
| 38 |
st.session_state.logged_in = False
|
| 39 |
st.experimental_rerun()
|
| 40 |
|
| 41 |
+
# Añadir una línea divisoria
|
| 42 |
st.markdown("---")
|
| 43 |
+
|
| 44 |
+
tab1, tab2, tab3, tab4 = st.tabs(["Análisis morfosintáctico", "Análisis semántico", "Análisis del discurso", "Mi Progreso"])
|
| 45 |
+
|
| 46 |
with tab1:
|
| 47 |
+
display_morphosyntax_analysis_interface(nlp_models, lang_code)
|
| 48 |
with tab2:
|
| 49 |
+
display_semantic_analysis_interface(nlp_models, lang_code)
|
| 50 |
with tab3:
|
| 51 |
display_discourse_analysis_interface(nlp_models, lang_code)
|
| 52 |
with tab4:
|
|
|
|
| 55 |
def main():
|
| 56 |
if not initialize_mongodb_connection():
|
| 57 |
st.warning("La conexión a la base de datos MongoDB no está disponible. Algunas funciones pueden no estar operativas.")
|
| 58 |
+
|
| 59 |
if 'logged_in' not in st.session_state:
|
| 60 |
st.session_state.logged_in = False
|
| 61 |
+
|
| 62 |
if not st.session_state.logged_in:
|
| 63 |
login_register_page()
|
| 64 |
else:
|