AIdeaText commited on
Commit
b2eaa61
·
verified ·
1 Parent(s): bd62b3e

Update modules/ui/ui.py

Browse files

Introducir texto directamente en un área de texto.
Cargar un archivo de texto como alternativa.
Analizar el texto de cualquiera de las dos fuentes.
Mostrar los resultados del análisis, incluyendo entidades identificadas, conceptos clave y relaciones semánticas.

Files changed (1) hide show
  1. modules/ui/ui.py +29 -8
modules/ui/ui.py CHANGED
@@ -585,22 +585,43 @@ def display_semantic_analysis_interface(nlp_models, lang_code):
585
  t = translations[lang_code]
586
  st.header(t['title'])
587
 
 
 
 
 
 
 
 
588
  # Opción para cargar archivo
589
  uploaded_file = st.file_uploader(t['file_uploader'], type=['txt'])
590
 
591
  if st.button(t['analyze_button']):
592
- if uploaded_file is not None:
593
- text_content = uploaded_file.getvalue().decode('utf-8')
594
-
 
 
 
595
  # Realizar el análisis
596
- relations_graph = perform_semantic_analysis(text_content, nlp_models[lang_code], lang_code)
597
-
 
 
 
 
 
 
 
 
 
 
 
598
  # Mostrar el gráfico de relaciones semánticas
599
  with st.expander(t['semantic_relations'], expanded=True):
600
- st.pyplot(relations_graph)
601
-
602
  # Guardar el resultado del análisis
603
- if store_semantic_result(st.session_state.username, text_content, relations_graph):
604
  st.success(t['success_message'])
605
  else:
606
  st.error(t['error_message'])
 
585
  t = translations[lang_code]
586
  st.header(t['title'])
587
 
588
+ # Opción para introducir texto
589
+ text_input = st.text_area(
590
+ t['text_input_label'],
591
+ height=150,
592
+ placeholder=t['text_input_placeholder'],
593
+ )
594
+
595
  # Opción para cargar archivo
596
  uploaded_file = st.file_uploader(t['file_uploader'], type=['txt'])
597
 
598
  if st.button(t['analyze_button']):
599
+ if text_input or uploaded_file is not None:
600
+ if uploaded_file:
601
+ text_content = uploaded_file.getvalue().decode('utf-8')
602
+ else:
603
+ text_content = text_input
604
+
605
  # Realizar el análisis
606
+ analysis_result = perform_semantic_analysis(text_content, nlp_models[lang_code], lang_code)
607
+
608
+ # Mostrar entidades identificadas
609
+ with st.expander(t['identified_entities'], expanded=True):
610
+ for entity in analysis_result['entities']:
611
+ st.markdown(f"**{entity['text']}** ({entity['label']})")
612
+ st.markdown(f"Contexto: *{entity['context']}*")
613
+
614
+ # Mostrar conceptos clave
615
+ with st.expander(t['key_concepts'], expanded=True):
616
+ for concept, freq in analysis_result['key_concepts']:
617
+ st.markdown(f"- {concept}: {freq}")
618
+
619
  # Mostrar el gráfico de relaciones semánticas
620
  with st.expander(t['semantic_relations'], expanded=True):
621
+ st.pyplot(analysis_result['relations_graph'])
622
+
623
  # Guardar el resultado del análisis
624
+ if store_semantic_result(st.session_state.username, text_content, analysis_result):
625
  st.success(t['success_message'])
626
  else:
627
  st.error(t['error_message'])