Update modules/ui.py
Browse files- modules/ui.py +48 -0
modules/ui.py
CHANGED
|
@@ -283,6 +283,54 @@ def display_text_analysis_interface(nlp_models, lang_code):
|
|
| 283 |
st.error("Hubo un problema al guardar el análisis. Por favor, inténtelo de nuevo.")
|
| 284 |
st.error(f"Falló el guardado del análisis. Username: {st.session_state.username}")
|
| 285 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
##################################################################################################
|
| 287 |
def get_chatbot_response(input_text):
|
| 288 |
# Esta función debe ser implementada o importada de otro módulo
|
|
|
|
| 283 |
st.error("Hubo un problema al guardar el análisis. Por favor, inténtelo de nuevo.")
|
| 284 |
st.error(f"Falló el guardado del análisis. Username: {st.session_state.username}")
|
| 285 |
|
| 286 |
+
###############################################################################################################
|
| 287 |
+
def display_semantic_analysis_interface(nlp_models, lang_code):
|
| 288 |
+
translations = {
|
| 289 |
+
'es': {
|
| 290 |
+
'title': "AIdeaText - Análisis semántico",
|
| 291 |
+
'input_label': "Ingrese un texto para analizar (máx. 5,000 palabras):",
|
| 292 |
+
'input_placeholder': "El objetivo de esta aplicación es que mejore sus habilidades de redacción...",
|
| 293 |
+
'analyze_button': "Analizar texto",
|
| 294 |
+
'network_diagram': "Análisis semántico: Diagrama de red",
|
| 295 |
+
},
|
| 296 |
+
'en': {
|
| 297 |
+
'title': "AIdeaText - Semantic Analysis",
|
| 298 |
+
'input_label': "Enter a text to analyze (max 5,000 words):",
|
| 299 |
+
'input_placeholder': "The goal of this app is for you to improve your writing skills...",
|
| 300 |
+
'analyze_button': "Analyze text",
|
| 301 |
+
'network_diagram': "Semantic analysis: Network diagram",
|
| 302 |
+
},
|
| 303 |
+
'fr': {
|
| 304 |
+
'title': "AIdeaText - Analyse sémantique",
|
| 305 |
+
'input_label': "Entrez un texte à analyser (max 5 000 mots) :",
|
| 306 |
+
'input_placeholder': "Le but de cette application est d'améliorer vos compétences en rédaction...",
|
| 307 |
+
'analyze_button': "Analyser le texte",
|
| 308 |
+
'network_diagram': "Analyse sémantique : Diagramme de réseau",
|
| 309 |
+
}
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
t = translations[lang_code]
|
| 313 |
+
|
| 314 |
+
if 'semantic_input_text' not in st.session_state:
|
| 315 |
+
st.session_state.semantic_input_text = ""
|
| 316 |
+
|
| 317 |
+
sentence_input = st.text_area(
|
| 318 |
+
t['input_label'],
|
| 319 |
+
height=150,
|
| 320 |
+
placeholder=t['input_placeholder'],
|
| 321 |
+
value=st.session_state.semantic_input_text,
|
| 322 |
+
key=f"semantic_text_input_{lang_code}"
|
| 323 |
+
)
|
| 324 |
+
st.session_state.semantic_input_text = sentence_input
|
| 325 |
+
|
| 326 |
+
if st.button(t['analyze_button'], key=f"semantic_analyze_button_{lang_code}"):
|
| 327 |
+
if sentence_input:
|
| 328 |
+
doc = nlp_models[lang_code](sentence_input)
|
| 329 |
+
|
| 330 |
+
with st.expander(t['network_diagram'], expanded=True):
|
| 331 |
+
fig = visualize_syntax(sentence_input, nlp_models[lang_code], lang_code)
|
| 332 |
+
st.pyplot(fig)
|
| 333 |
+
|
| 334 |
##################################################################################################
|
| 335 |
def get_chatbot_response(input_text):
|
| 336 |
# Esta función debe ser implementada o importada de otro módulo
|