|
import streamlit as st
|
|
from ..text_analysis.morpho_analysis import perform_advanced_morphosyntactic_analysis
|
|
from ..text_analysis.semantic_analysis import perform_semantic_analysis
|
|
from ..text_analysis.discourse_analysis import perform_discourse_analysis
|
|
|
|
class AIdeaTextChatbot:
|
|
def __init__(self):
|
|
self.conversation_history = []
|
|
|
|
def handle_morphosyntactic_input(self, user_input, lang_code, nlp_models, t):
|
|
if user_input.startswith('/analisis_morfosintactico'):
|
|
text_to_analyze = user_input.split('[', 1)[1].rsplit(']', 1)[0]
|
|
result = perform_advanced_morphosyntactic_analysis(text_to_analyze, nlp_models[lang_code])
|
|
if result is None or 'arc_diagrams' not in result:
|
|
return t.get('morphosyntactic_analysis_error', 'Error en el análisis morfosintáctico'), None, None
|
|
return t.get('morphosyntactic_analysis_completed', 'Análisis morfosintáctico completado'), result['arc_diagrams'], result
|
|
else:
|
|
|
|
return self.generate_response(user_input, lang_code), None, None
|
|
|
|
|
|
def handle_semantic_input(self, user_input, lang_code, nlp_models, t):
|
|
|
|
pass
|
|
|
|
def handle_discourse_input(self, user_input, lang_code, nlp_models, t):
|
|
|
|
pass
|
|
|
|
def handle_generate_response(self, prompt, lang_code):
|
|
|
|
|
|
pass
|
|
|
|
def initialize_chatbot():
|
|
return AIdeaTextChatbot()
|
|
|
|
def process_chat_input(user_input, lang_code, nlp_models, analysis_type, t, file_contents=None):
|
|
chatbot = st.session_state.get('aideatext_chatbot')
|
|
if not chatbot:
|
|
chatbot = initialize_chatbot()
|
|
st.session_state.aideatext_chatbot = chatbot
|
|
|
|
if analysis_type == 'morphosyntactic':
|
|
return chatbot.handle_morphosyntactic_input(user_input, lang_code, nlp_models, t)
|
|
|