File size: 2,870 Bytes
714f0f2
6e99cf7
 
 
 
 
714f0f2
ff017e0
 
ea113e2
 
ff017e0
 
0a59cd4
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
63
64
65
66
67
68
69
70
71
72
## app.py
import sys
import os

# Add the project root directory to Python's module search path
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

# Configuraci贸n de la p谩gina
st.set_page_config(page_title="AIdeaText", layout="wide", page_icon="random")

def main_app():
    # Cargar modelos de spaCy (aseg煤rate de que esta funci贸n est茅 definida en alg煤n lugar)
    nlp_models = load_spacy_models()

    # Selecci贸n de idioma
    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]

    # Crear dos columnas: una para chat y otra para an谩lisis
    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":
            if st.button("Ver mi progreso"):
                student_data = get_student_data(st.session_state.username)
                if student_data:
                    display_student_progress(student_data)
                else:
                    st.warning("No se encontraron datos para este estudiante")
            
            display_text_analysis_interface(nlp_models, lang_code)

        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.experimental_rerun()
        main_app()

if __name__ == "__main__":
    main()