File size: 2,750 Bytes
3b70165
8b38f52
813a290
8b38f52
3b70165
 
 
ff864f2
6bfe703
8e75705
f89a64b
3b70165
8b38f52
 
 
 
ff864f2
 
 
 
 
 
 
8b38f52
813a290
3b70165
9173494
 
 
aa91d57
1e863b9
 
 
3b70165
88aea46
1e863b9
 
c4c5749
88aea46
1e863b9
 
8b38f52
ff864f2
9173494
ff864f2
f89a64b
ff864f2
8b38f52
ff864f2
8b38f52
ff864f2
8b38f52
4cf9d21
8b38f52
f89a64b
 
813a290
8b38f52
c5c97b1
 
 
ff864f2
c5c97b1
 
ff864f2
c5c97b1
 
 
 
 
813a290
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# app.py
import streamlit as st
from modules.database import initialize_mongodb_connection
from modules.auth import authenticate_user, get_user_role, register_user
from modules.ui import (
    login_register_page, 
    display_morphosyntax_analysis_interface, 
    display_semantic_analysis_interface,
    display_discourse_analysis_interface, 
    display_student_progress,
    display_chatbot_interface
)
from modules.spacy_utils import load_spacy_models

st.set_page_config(page_title="AIdeaText", layout="wide", page_icon="random")

# Cargar los modelos de spaCy una vez al inicio de la aplicación
@st.cache_resource
def load_models():
    return load_spacy_models()

nlp_models = load_models()

def logged_in_interface():
    languages = {'Español': 'es', 'English': 'en', 'Français': 'fr'}
    
    # Crear un contenedor para la barra superior
    with st.container():
        # Usar más columnas para un mejor control del espacio
        col1, col2, col3, col4, col5 = st.columns([1, 1, 0.8, 1, 1])
        with col1:
            st.markdown(f"<h3 style='margin-bottom: 0;'>Bienvenido, {st.session_state.username}</h3>", unsafe_allow_html=True)
        with col3:
            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)
        with col4:
            selected_lang = st.selectbox("", list(languages.keys()), key="language_selector", label_visibility="collapsed")
            lang_code = languages[selected_lang]
        with col5:
            if st.button("Cerrar Sesión", key="logout_button"):
                st.session_state.logged_in = False
                st.experimental_rerun()

    # Añadir una línea divisoria
    st.markdown("---")

    tab1, tab2, tab3, tab4, tab5 = st.tabs(["Análisis morfosintáctico", "Análisis semántico", "Análisis del discurso", "Chat con Llama2", "Mi Progreso"])

    with tab1:
        display_morphosyntax_analysis_interface(nlp_models, lang_code)
    with tab2:
        display_semantic_analysis_interface(nlp_models, lang_code)
    with tab3:
        display_discourse_analysis_interface(nlp_models, lang_code)
    with tab4:
        display_chatbot_interface(lang_code)
    with tab5:
        display_student_progress(st.session_state.username, lang_code)

def main():
    if not initialize_mongodb_connection():
        st.warning("La conexión a la base de datos MongoDB no está disponible. Algunas funciones pueden no estar operativas.")

    if 'logged_in' not in st.session_state:
        st.session_state.logged_in = False

    if not st.session_state.logged_in:
        login_register_page()
    else:
        logged_in_interface()

if __name__ == "__main__":
    main()