Merge branch #AIdeaText/test' into 'AIdeaText/test2'
Browse files- app.py +40 -11
- modules/ui/ui.py +53 -13
app.py
CHANGED
|
@@ -91,23 +91,51 @@ def main():
|
|
| 91 |
def logged_in_interface():
|
| 92 |
languages = {'Español': 'es', 'English': 'en', 'Français': 'fr'}
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
# Crear un contenedor para la barra superior
|
| 95 |
with st.container():
|
| 96 |
# Usar más columnas para un mejor control del espacio
|
| 97 |
col1, col2, col3, col4, col5 = st.columns([1, 1, 0.8, 1, 1])
|
| 98 |
with col1:
|
| 99 |
-
st.markdown(f"<h3 style='margin-bottom: 0;'>
|
| 100 |
with col3:
|
| 101 |
-
st.markdown("<p style='font-size: 1.2rem; margin-bottom: 0; padding-top: 15px;'>
|
| 102 |
with col4:
|
| 103 |
st.markdown("<div style='padding-top: 15px;'>", unsafe_allow_html=True)
|
| 104 |
-
selected_lang = st.selectbox("", list(languages.keys()), key="language_selector", label_visibility="collapsed")
|
| 105 |
st.markdown("</div>", unsafe_allow_html=True)
|
| 106 |
lang_code = languages[selected_lang]
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
with col5:
|
| 109 |
st.markdown("<div style='padding-top: 15px;'>", unsafe_allow_html=True)
|
| 110 |
-
if st.button(
|
| 111 |
st.session_state.logged_in = False
|
| 112 |
st.experimental_rerun()
|
| 113 |
st.markdown("</div>", unsafe_allow_html=True)
|
|
@@ -115,20 +143,21 @@ def logged_in_interface():
|
|
| 115 |
# Añadir una línea divisoria
|
| 116 |
st.markdown("---")
|
| 117 |
|
| 118 |
-
|
|
|
|
| 119 |
|
| 120 |
with tab1:
|
| 121 |
-
display_morphosyntax_analysis_interface(nlp_models,
|
| 122 |
with tab2:
|
| 123 |
-
display_semantic_analysis_interface(nlp_models,
|
| 124 |
with tab3:
|
| 125 |
-
display_discourse_analysis_interface(nlp_models,
|
| 126 |
with tab4:
|
| 127 |
-
display_chatbot_interface(
|
| 128 |
with tab5:
|
| 129 |
-
display_student_progress(st.session_state.username,
|
| 130 |
with tab6:
|
| 131 |
-
display_feedback_form(
|
| 132 |
|
| 133 |
###################################################################################################################
|
| 134 |
if __name__ == "__main__":
|
|
|
|
| 91 |
def logged_in_interface():
|
| 92 |
languages = {'Español': 'es', 'English': 'en', 'Français': 'fr'}
|
| 93 |
|
| 94 |
+
translations = {
|
| 95 |
+
'es': {
|
| 96 |
+
'welcome': "Bienvenido",
|
| 97 |
+
'select_language': "Selecciona el idioma del texto que analizarás",
|
| 98 |
+
'logout': "Cerrar Sesión",
|
| 99 |
+
'tabs': ["Análisis morfosintáctico", "Análisis semántico", "Análisis del discurso", "Chat con Llama2", "Mi Progreso", "Formulario de Retroalimentación"]
|
| 100 |
+
},
|
| 101 |
+
'en': {
|
| 102 |
+
'welcome': "Welcome",
|
| 103 |
+
'select_language': "Select the language of the text you will analyze",
|
| 104 |
+
'logout': "Log Out",
|
| 105 |
+
'tabs': ["Morphosyntactic Analysis", "Semantic Analysis", "Discourse Analysis", "Chat with Llama2", "My Progress", "Feedback Form"]
|
| 106 |
+
},
|
| 107 |
+
'fr': {
|
| 108 |
+
'welcome': "Bienvenue",
|
| 109 |
+
'select_language': "Sélectionnez la langue du texte que vous allez analyser",
|
| 110 |
+
'logout': "Déconnexion",
|
| 111 |
+
'tabs': ["Analyse morphosyntaxique", "Analyse sémantique", "Analyse du discours", "Chat avec Llama2", "Mon Progrès", "Formulaire de Rétroaction"]
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
# Inicializar el idioma si no está establecido
|
| 116 |
+
if 'current_lang' not in st.session_state:
|
| 117 |
+
st.session_state.current_lang = 'es' # Idioma por defecto
|
| 118 |
+
|
| 119 |
# Crear un contenedor para la barra superior
|
| 120 |
with st.container():
|
| 121 |
# Usar más columnas para un mejor control del espacio
|
| 122 |
col1, col2, col3, col4, col5 = st.columns([1, 1, 0.8, 1, 1])
|
| 123 |
with col1:
|
| 124 |
+
st.markdown(f"<h3 style='margin-bottom: 0;'>{translations[st.session_state.current_lang]['welcome']}, {st.session_state.username}</h3>", unsafe_allow_html=True)
|
| 125 |
with col3:
|
| 126 |
+
st.markdown(f"<p style='font-size: 1.2rem; margin-bottom: 0; padding-top: 15px;'>{translations[st.session_state.current_lang]['select_language']}</p>", unsafe_allow_html=True)
|
| 127 |
with col4:
|
| 128 |
st.markdown("<div style='padding-top: 15px;'>", unsafe_allow_html=True)
|
| 129 |
+
selected_lang = st.selectbox("", list(languages.keys()), key="language_selector", label_visibility="collapsed", index=list(languages.values()).index(st.session_state.current_lang))
|
| 130 |
st.markdown("</div>", unsafe_allow_html=True)
|
| 131 |
lang_code = languages[selected_lang]
|
| 132 |
+
if st.session_state.current_lang != lang_code:
|
| 133 |
+
st.session_state.current_lang = lang_code
|
| 134 |
+
st.experimental_rerun()
|
| 135 |
|
| 136 |
with col5:
|
| 137 |
st.markdown("<div style='padding-top: 15px;'>", unsafe_allow_html=True)
|
| 138 |
+
if st.button(translations[st.session_state.current_lang]['logout'], key="logout_button"):
|
| 139 |
st.session_state.logged_in = False
|
| 140 |
st.experimental_rerun()
|
| 141 |
st.markdown("</div>", unsafe_allow_html=True)
|
|
|
|
| 143 |
# Añadir una línea divisoria
|
| 144 |
st.markdown("---")
|
| 145 |
|
| 146 |
+
# Usar los nombres de tabs traducidos
|
| 147 |
+
tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs(translations[st.session_state.current_lang]['tabs'])
|
| 148 |
|
| 149 |
with tab1:
|
| 150 |
+
display_morphosyntax_analysis_interface(nlp_models, st.session_state.current_lang)
|
| 151 |
with tab2:
|
| 152 |
+
display_semantic_analysis_interface(nlp_models, st.session_state.current_lang)
|
| 153 |
with tab3:
|
| 154 |
+
display_discourse_analysis_interface(nlp_models, st.session_state.current_lang)
|
| 155 |
with tab4:
|
| 156 |
+
display_chatbot_interface(st.session_state.current_lang)
|
| 157 |
with tab5:
|
| 158 |
+
display_student_progress(st.session_state.username, st.session_state.current_lang)
|
| 159 |
with tab6:
|
| 160 |
+
display_feedback_form(st.session_state.current_lang)
|
| 161 |
|
| 162 |
###################################################################################################################
|
| 163 |
if __name__ == "__main__":
|
modules/ui/ui.py
CHANGED
|
@@ -158,25 +158,47 @@ def admin_page():
|
|
| 158 |
|
| 159 |
##################################################################################################
|
| 160 |
def user_page():
|
| 161 |
-
st.
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
-
# Aquí puedes añadir las funcionalidades para el usuario estudiante
|
| 165 |
-
# Por ejemplo:
|
| 166 |
-
tabs = st.tabs(["Análisis Morfosintáctico", "Análisis Semántico", "Análisis del Discurso", "Chat", "Mi Progreso", "Formulario de Retroalimentación"])
|
| 167 |
-
|
| 168 |
with tabs[0]:
|
| 169 |
-
display_morphosyntax_analysis_interface(nlp_models,
|
| 170 |
with tabs[1]:
|
| 171 |
-
display_semantic_analysis_interface(nlp_models,
|
| 172 |
with tabs[2]:
|
| 173 |
-
display_discourse_analysis_interface(nlp_models,
|
| 174 |
with tabs[3]:
|
| 175 |
-
display_chatbot_interface(
|
| 176 |
with tabs[4]:
|
| 177 |
-
display_student_progress(st.session_state.username,
|
| 178 |
with tabs[5]:
|
| 179 |
-
display_feedback_form(
|
| 180 |
|
| 181 |
##################################################################################################
|
| 182 |
def display_videos_and_info():
|
|
@@ -237,6 +259,7 @@ def register_form():
|
|
| 237 |
|
| 238 |
################################################################################
|
| 239 |
def display_feedback_form(lang_code):
|
|
|
|
| 240 |
translations = {
|
| 241 |
'es': {
|
| 242 |
'title': "Formulario de Retroalimentación",
|
|
@@ -247,7 +270,24 @@ def display_feedback_form(lang_code):
|
|
| 247 |
'success': "¡Gracias por tu retroalimentación!",
|
| 248 |
'error': "Hubo un problema al enviar el formulario. Por favor, intenta de nuevo."
|
| 249 |
},
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
}
|
| 252 |
|
| 253 |
t = translations[lang_code]
|
|
|
|
| 158 |
|
| 159 |
##################################################################################################
|
| 160 |
def user_page():
|
| 161 |
+
# Asumimos que el idioma seleccionado está almacenado en st.session_state.lang_code
|
| 162 |
+
# Si no está definido, usamos 'es' como valor predeterminado
|
| 163 |
+
lang_code = st.session_state.get('lang_code', 'es')
|
| 164 |
+
|
| 165 |
+
translations = {
|
| 166 |
+
'es': {
|
| 167 |
+
'welcome': "Bienvenido a AIdeaText",
|
| 168 |
+
'hello': "Hola",
|
| 169 |
+
'tabs': ["Análisis Morfosintáctico", "Análisis Semántico", "Análisis del Discurso", "Chat", "Mi Progreso", "Formulario de Retroalimentación"]
|
| 170 |
+
},
|
| 171 |
+
'en': {
|
| 172 |
+
'welcome': "Welcome to AIdeaText",
|
| 173 |
+
'hello': "Hello",
|
| 174 |
+
'tabs': ["Morphosyntactic Analysis", "Semantic Analysis", "Discourse Analysis", "Chat", "My Progress", "Feedback Form"]
|
| 175 |
+
},
|
| 176 |
+
'fr': {
|
| 177 |
+
'welcome': "Bienvenue à AIdeaText",
|
| 178 |
+
'hello': "Bonjour",
|
| 179 |
+
'tabs': ["Analyse Morphosyntaxique", "Analyse Sémantique", "Analyse du Discours", "Chat", "Mon Progrès", "Formulaire de Rétroaction"]
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
t = translations[lang_code]
|
| 184 |
+
|
| 185 |
+
st.title(t['welcome'])
|
| 186 |
+
st.write(f"{t['hello']}, {st.session_state.username}")
|
| 187 |
+
|
| 188 |
+
tabs = st.tabs(t['tabs'])
|
| 189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
with tabs[0]:
|
| 191 |
+
display_morphosyntax_analysis_interface(nlp_models, lang_code)
|
| 192 |
with tabs[1]:
|
| 193 |
+
display_semantic_analysis_interface(nlp_models, lang_code)
|
| 194 |
with tabs[2]:
|
| 195 |
+
display_discourse_analysis_interface(nlp_models, lang_code)
|
| 196 |
with tabs[3]:
|
| 197 |
+
display_chatbot_interface(lang_code)
|
| 198 |
with tabs[4]:
|
| 199 |
+
display_student_progress(st.session_state.username, lang_code)
|
| 200 |
with tabs[5]:
|
| 201 |
+
display_feedback_form(lang_code)
|
| 202 |
|
| 203 |
##################################################################################################
|
| 204 |
def display_videos_and_info():
|
|
|
|
| 259 |
|
| 260 |
################################################################################
|
| 261 |
def display_feedback_form(lang_code):
|
| 262 |
+
logging.info(f"display_feedback_form called with lang_code: {lang_code}")
|
| 263 |
translations = {
|
| 264 |
'es': {
|
| 265 |
'title': "Formulario de Retroalimentación",
|
|
|
|
| 270 |
'success': "¡Gracias por tu retroalimentación!",
|
| 271 |
'error': "Hubo un problema al enviar el formulario. Por favor, intenta de nuevo."
|
| 272 |
},
|
| 273 |
+
'en': {
|
| 274 |
+
'title': "Feedback Form",
|
| 275 |
+
'name': "Name",
|
| 276 |
+
'email': "Email",
|
| 277 |
+
'feedback': "Your feedback",
|
| 278 |
+
'submit': "Submit",
|
| 279 |
+
'success': "Thank you for your feedback!",
|
| 280 |
+
'error': "There was a problem submitting the form. Please try again."
|
| 281 |
+
},
|
| 282 |
+
'fr': {
|
| 283 |
+
'title': "Formulaire de Rétroaction",
|
| 284 |
+
'name': "Nom",
|
| 285 |
+
'email': "Adresse e-mail",
|
| 286 |
+
'feedback': "Votre rétroaction",
|
| 287 |
+
'submit': "Envoyer",
|
| 288 |
+
'success': "Merci pour votre rétroaction !",
|
| 289 |
+
'error': "Un problème est survenu lors de l'envoi du formulaire. Veuillez réessayer."
|
| 290 |
+
}
|
| 291 |
}
|
| 292 |
|
| 293 |
t = translations[lang_code]
|