AIdeaText commited on
Commit
813a290
1 Parent(s): 6fc62da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -73
app.py CHANGED
@@ -1,8 +1,8 @@
 
1
  import streamlit as st
2
- from modules.database import initialize_mongodb_connection, get_student_data, store_analysis_result
3
  from modules.auth import authenticate_user, get_user_role, register_user
4
- from modules.morpho_analysis import get_repeated_words_colors, highlight_repeated_words, POS_COLORS, POS_TRANSLATIONS
5
- from modules.syntax_analysis import visualize_syntax
6
  from modules.spacy_utils import load_spacy_models
7
  import time
8
 
@@ -20,53 +20,12 @@ def main():
20
  else:
21
  logged_in_interface()
22
 
23
- def login_register_page():
24
- st.title("AIdeaText")
25
-
26
- tab1, tab2 = st.tabs(["Iniciar Sesión", "Registrarse"])
27
-
28
- with tab1:
29
- login_form()
30
-
31
- with tab2:
32
- register_form()
33
-
34
- def login_form():
35
- username = st.text_input("Usuario")
36
- password = st.text_input("Contraseña", type='password')
37
- captcha_answer = st.text_input("Captcha: ¿Cuánto es 2 + 3?")
38
-
39
- if st.button("Iniciar Sesión"):
40
- if captcha_answer == "5":
41
- if authenticate_user(username, password):
42
- st.success(f"Bienvenido, {username}!")
43
- st.session_state.logged_in = True
44
- st.session_state.username = username
45
- st.session_state.role = get_user_role(username)
46
- time.sleep(2)
47
- st.experimental_rerun()
48
- else:
49
- st.error("Usuario o contraseña incorrectos")
50
- else:
51
- st.error("Captcha incorrecto")
52
-
53
- def register_form():
54
- new_username = st.text_input("Nuevo Usuario")
55
- new_password = st.text_input("Nueva Contraseña", type='password')
56
- carrera = st.text_input("Carrera")
57
- captcha_answer = st.text_input("Captcha: ¿Cuánto es 3 + 4?")
58
-
59
- if st.button("Registrarse"):
60
- if captcha_answer == "7":
61
- additional_info = {'carrera': carrera}
62
- if register_user(new_username, new_password, additional_info):
63
- st.success("Registro exitoso. Por favor, inicia sesión.")
64
- else:
65
- st.error("El usuario ya existe o ocurrió un error durante el registro")
66
- else:
67
- st.error("Captcha incorrecto")
68
-
69
  def logged_in_interface():
 
 
 
 
 
70
  st.sidebar.title(f"Bienvenido, {st.session_state.username}")
71
  if st.sidebar.button("Cerrar Sesión"):
72
  st.session_state.logged_in = False
@@ -75,34 +34,18 @@ def logged_in_interface():
75
  tab1, tab2, tab3, tab4 = st.tabs(["Análisis morfosintáctico", "Análisis semántico", "Análisis semántico discursivo", "Mi Progreso"])
76
 
77
  with tab1:
78
- morphosyntactic_analysis()
79
 
80
  with tab2:
81
- semantic_analysis()
 
82
 
83
  with tab3:
84
- discourse_semantic_analysis()
 
85
 
86
  with tab4:
87
- if st.session_state.role == "Estudiante":
88
- display_student_progress(st.session_state.username)
89
- elif st.session_state.role == "Profesor":
90
- display_teacher_interface()
91
-
92
- def morphosyntactic_analysis():
93
- st.header("Análisis morfosintáctico")
94
- # Aquí va el código para el análisis morfosintáctico
95
-
96
- def semantic_analysis():
97
- st.header("Análisis semántico")
98
- # Aquí va el código para el análisis semántico
99
-
100
- def discourse_semantic_analysis():
101
- st.header("Análisis semántico discursivo")
102
- # Aquí va el código para el análisis semántico discursivo
103
-
104
- def display_student_progress(username):
105
- # Código existente para mostrar el progreso del estudiante
106
 
107
- if __name__ == "__main__":
108
- main()
 
1
+ #app.py
2
  import streamlit as st
3
+ from modules.database import initialize_mongodb_connection
4
  from modules.auth import authenticate_user, get_user_role, register_user
5
+ from modules.ui import login_register_page, display_student_progress, display_text_analysis_interface
 
6
  from modules.spacy_utils import load_spacy_models
7
  import time
8
 
 
20
  else:
21
  logged_in_interface()
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  def logged_in_interface():
24
+ nlp_models = load_spacy_models()
25
+ languages = {'Español': 'es', 'English': 'en', 'Français': 'fr'}
26
+ selected_lang = st.sidebar.selectbox("Select Language / Seleccione el idioma / Choisissez la langue", list(languages.keys()))
27
+ lang_code = languages[selected_lang]
28
+
29
  st.sidebar.title(f"Bienvenido, {st.session_state.username}")
30
  if st.sidebar.button("Cerrar Sesión"):
31
  st.session_state.logged_in = False
 
34
  tab1, tab2, tab3, tab4 = st.tabs(["Análisis morfosintáctico", "Análisis semántico", "Análisis semántico discursivo", "Mi Progreso"])
35
 
36
  with tab1:
37
+ display_text_analysis_interface(nlp_models, lang_code)
38
 
39
  with tab2:
40
+ st.header("Análisis semántico")
41
+ st.write("Esta función aún no está implementada.")
42
 
43
  with tab3:
44
+ st.header("Análisis semántico discursivo")
45
+ st.write("Esta función aún no está implementada.")
46
 
47
  with tab4:
48
+ display_student_progress(st.session_state.username, lang_code)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
+ if __name__ == "__main__":
51
+ main()