Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	Update modules/morphosyntax/morphosyntax_process.py
Browse files
    	
        modules/morphosyntax/morphosyntax_process.py
    CHANGED
    
    | @@ -1,29 +1,36 @@ | |
| 1 | 
            -
            #modules/morphosyntax/morphosyntax_process.py
         | 
| 2 | 
            -
            import streamlit as st
         | 
| 3 | 
            -
            from ..text_analysis.morpho_analysis import perform_advanced_morphosyntactic_analysis
         | 
| 4 | 
            -
            from ..database.morphosintax_mongo_db import store_student_morphosyntax_result
         | 
| 5 | 
            -
            from ..chatbot.chatbot import process_chat_input
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            def process_morphosyntactic_input(user_input, lang_code, nlp_models, t):
         | 
| 8 | 
            -
                if user_input.startswith('/analisis_morfosintactico'):
         | 
| 9 | 
            -
                    text_to_analyze = user_input.split('[', 1)[1].rsplit(']', 1)[0]
         | 
| 10 | 
            -
                    result = perform_advanced_morphosyntactic_analysis(text_to_analyze, nlp_models[lang_code])
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                    if result is None or 'arc_diagrams' not in result:
         | 
| 13 | 
            -
                        response = t.get('morphosyntactic_analysis_error', 'Error in morphosyntactic analysis')
         | 
| 14 | 
            -
                        return response, None, None
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                    response = t.get('morphosyntactic_analysis_completed', 'Morphosyntactic analysis completed')
         | 
| 17 | 
            -
                    visualizations = result['arc_diagrams']
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                    store_student_morphosyntax_result(
         | 
| 20 | 
            -
                        st.session_state.username,
         | 
| 21 | 
            -
                        text_to_analyze,
         | 
| 22 | 
            -
                        visualizations
         | 
| 23 | 
            -
                    )
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                    return response, visualizations, result
         | 
| 26 | 
            -
                else:
         | 
| 27 | 
            -
                    chatbot = st.session_state.morphosyntax_chat_input
         | 
| 28 | 
            -
                    response = chatbot.generate_response(user_input, lang_code)
         | 
| 29 | 
            -
                    return response, None, None
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            #modules/morphosyntax/morphosyntax_process.py
         | 
| 2 | 
            +
            import streamlit as st
         | 
| 3 | 
            +
            from ..text_analysis.morpho_analysis import perform_advanced_morphosyntactic_analysis
         | 
| 4 | 
            +
            from ..database.morphosintax_mongo_db import store_student_morphosyntax_result
         | 
| 5 | 
            +
            from ..chatbot.chatbot import process_chat_input
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            def process_morphosyntactic_input(user_input, lang_code, nlp_models, t):
         | 
| 8 | 
            +
                if user_input.startswith('/analisis_morfosintactico'):
         | 
| 9 | 
            +
                    text_to_analyze = user_input.split('[', 1)[1].rsplit(']', 1)[0]
         | 
| 10 | 
            +
                    result = perform_advanced_morphosyntactic_analysis(text_to_analyze, nlp_models[lang_code])
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                    if result is None or 'arc_diagrams' not in result:
         | 
| 13 | 
            +
                        response = t.get('morphosyntactic_analysis_error', 'Error in morphosyntactic analysis')
         | 
| 14 | 
            +
                        return response, None, None
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                    response = t.get('morphosyntactic_analysis_completed', 'Morphosyntactic analysis completed')
         | 
| 17 | 
            +
                    visualizations = result['arc_diagrams']
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    store_student_morphosyntax_result(
         | 
| 20 | 
            +
                        st.session_state.username,
         | 
| 21 | 
            +
                        text_to_analyze,
         | 
| 22 | 
            +
                        visualizations
         | 
| 23 | 
            +
                    )
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    return response, visualizations, result
         | 
| 26 | 
            +
                else:
         | 
| 27 | 
            +
                    chatbot = st.session_state.morphosyntax_chat_input
         | 
| 28 | 
            +
                    response = chatbot.generate_response(user_input, lang_code)
         | 
| 29 | 
            +
                    return response, None, None
         | 
| 30 | 
            +
             | 
| 31 | 
            +
             | 
| 32 | 
            +
            def format_analysis_response(result, t, lang_code):
         | 
| 33 | 
            +
                # Formatea la respuesta del análisis en texto legible
         | 
| 34 | 
            +
                # Usa las traducciones (t) para los títulos y etiquetas
         | 
| 35 | 
            +
                # ...
         | 
| 36 | 
            +
                pass
         | 
