| |
| 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_student_progress, |
| display_morphosyntax_analysis_interface, |
| display_semantic_analysis_interface, |
| display_discourse_analysis_interface |
| ) |
| from modules.discourse_analysis import perform_discourse_analysis |
| from modules.spacy_utils import load_spacy_models |
| import time |
|
|
| st.set_page_config(page_title="AIdeaText", layout="wide", page_icon="random") |
|
|
| def logged_in_interface(): |
| if 'nlp_models' not in st.session_state: |
| st.session_state.nlp_models = load_spacy_models() |
| |
| languages = {'Español': 'es', 'English': 'en', 'Français': 'fr'} |
| |
| |
| with st.container(): |
| |
| 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: |
| st.markdown(""" |
| <style> |
| .stSelectbox { margin-left: -20px; } |
| div[data-testid="stSelectbox"] { |
| margin-top: 0px; |
| margin-bottom: 10px; |
| } |
| </style> |
| """, unsafe_allow_html=True) |
| selected_lang = st.selectbox("", list(languages.keys()), key="language_selector", label_visibility="collapsed") |
| lang_code = languages[selected_lang] |
| with col5: |
| st.markdown(""" |
| <style> |
| div[data-testid="stButton"] { |
| margin-top: 0px; |
| margin-bottom: 10px; |
| } |
| div[data-testid="stButton"] > button { |
| width: 100%; |
| padding: 8px 10px; |
| font-size: 1rem; |
| } |
| </style> |
| """, unsafe_allow_html=True) |
| if st.button("Cerrar Sesión", key="logout_button"): |
| st.session_state.logged_in = False |
| st.experimental_rerun() |
|
|
| st.markdown("---") |
| tab1, tab2, tab3, tab4 = st.tabs(["Análisis morfosintáctico", "Análisis semántico", "Análisis semántico discursivo", "Mi Progreso"]) |
| |
| with tab1: |
| display_morphosyntax_analysis_interface(st.session_state.nlp_models, lang_code) |
| with tab2: |
| display_semantic_analysis_interface(st.session_state.nlp_models, lang_code) |
| with tab3: |
| st.header("Análisis semántico discursivo") |
| st.write("Esta función aún no está implementada.") |
| with tab4: |
| 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() |