File size: 1,173 Bytes
c58df45 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from ..text_analysis.discourse_analysis import perform_discourse_analysis, compare_semantic_analysis
import streamlit as st
def process_discourse_input(user_input, lang_code, nlp_model, file_contents, t):
if user_input.startswith('/analisis_discurso'):
if file_contents is None or len(file_contents) != 2:
return t['no_files_uploaded'], None
text1, text2 = file_contents
result = perform_discourse_analysis(text1, text2, nlp_model, lang_code)
return t['discourse_analysis_completed'], (result['graph1'], result['graph2'])
elif user_input.startswith('/comparar'):
if file_contents is None or len(file_contents) != 2:
return t['no_files_uploaded'], None
text1, text2 = file_contents
comparison_result = compare_semantic_analysis(text1, text2, nlp_model, lang_code)
return t['comparison_completed'], comparison_result
else:
# Procesar otros tipos de inputs del usuario
chatbot = st.session_state.discourse_chatbot
response = chatbot.generate_response(user_input, lang_code, context=str(file_contents))
return response, None |