File size: 2,472 Bytes
714f0f2
6e99cf7
 
 
714f0f2
ff017e0
 
ea113e2
 
ff017e0
 
60795c9
ff017e0
 
 
 
 
078fcad
ff017e0
 
 
078fcad
ff017e0
078fcad
ff017e0
 
078fcad
ff017e0
 
078fcad
4ad877f
 
 
 
 
 
ff017e0
 
 
 
 
 
 
078fcad
ff017e0
 
078fcad
ff017e0
 
 
 
 
 
 
 
 
 
078fcad
ff017e0
 
 
 
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
## app.py
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

import streamlit as st
from modules.database import initialize_mongodb_connection, get_student_data, store_analysis_result
from modules.auth import authenticate_user, get_user_role
from modules.ui import login_page, register_page, display_chat_interface, display_student_progress, display_text_analysis_interface
from modules.morpho_analysis import get_repeated_words_colors, highlight_repeated_words, POS_COLORS, POS_TRANSLATIONS
from modules.syntax_analysis import visualize_syntax
from modules.spacy_utils import load_spacy_models

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

def main_app():
    nlp_models = load_spacy_models()
    
    languages = {'Espa帽ol': 'es', 'English': 'en', 'Fran莽ais': 'fr'}
    selected_lang = st.sidebar.selectbox("Select Language / Seleccione el idioma / Choisissez la langue", list(languages.keys()))
    lang_code = languages[selected_lang]
    
    col1, col2 = st.columns([1, 2])
    
    with col1:
        display_chat_interface()
    
    with col2:
        st.markdown("### AIdeaText - An谩lisis morfol贸gico y sint谩ctico")
        
        if st.session_state.role == "Estudiante":
            tabs = st.tabs(["An谩lisis de Texto", "Mi Progreso"])
            with tabs[0]:
                display_text_analysis_interface(nlp_models, lang_code)
            with tabs[1]:
                display_student_progress(st.session_state.username)
        elif st.session_state.role == "Profesor":
            st.write("Bienvenido, profesor. Aqu铆 podr谩s ver el progreso de tus estudiantes.")
            # Agregar l贸gica para mostrar el progreso de los estudiantes

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:
        menu = ["Iniciar Sesi贸n", "Registrarse"]
        choice = st.sidebar.selectbox("Menu", menu)
        if choice == "Iniciar Sesi贸n":
            login_page()
        elif choice == "Registrarse":
            register_page()
    else:
        if st.sidebar.button("Cerrar Sesi贸n"):
            st.session_state.logged_in = False
            st.rerun()
        main_app()

if __name__ == "__main__":
    main()