AIdeaText commited on
Commit
a22a995
verified
1 Parent(s): 7e3e643

Update modules/semantic/semantic_interface.py

Browse files
modules/semantic/semantic_interface.py CHANGED
@@ -38,7 +38,7 @@ def display_semantic_interface(lang_code, nlp_models, semantic_t):
38
  semantic_t: Diccionario de traducciones sem谩nticas
39
  """
40
  try:
41
- # Inicializar estados si no existen
42
  if 'semantic_analysis_counter' not in st.session_state:
43
  st.session_state.semantic_analysis_counter = 0
44
  if 'semantic_current_file' not in st.session_state:
@@ -46,10 +46,11 @@ def display_semantic_interface(lang_code, nlp_models, semantic_t):
46
  if 'semantic_page' not in st.session_state:
47
  st.session_state.semantic_page = 'semantic'
48
 
49
- # Contenedor fijo para los controles
50
  with st.container():
51
  st.markdown("### Controls")
52
- # Opci贸n para cargar archivo con key 煤nica
 
53
  uploaded_file = st.file_uploader(
54
  semantic_t.get('file_uploader', 'Upload a text file for analysis'),
55
  type=['txt'],
@@ -57,9 +58,10 @@ def display_semantic_interface(lang_code, nlp_models, semantic_t):
57
  on_change=lambda: setattr(st.session_state, 'semantic_current_file', uploaded_file)
58
  )
59
 
60
- # Bot贸n de an谩lisis deshabilitado si no hay archivo
61
- col1, col2, col3 = st.columns([1,2,1])
62
- with col1:
 
63
  analyze_button = st.button(
64
  semantic_t.get('analyze_button', 'Analyze text'),
65
  key=f"semantic_analyze_button_{st.session_state.semantic_analysis_counter}",
@@ -67,21 +69,22 @@ def display_semantic_interface(lang_code, nlp_models, semantic_t):
67
  use_container_width=True
68
  )
69
 
70
- # Bot贸n de exportaci贸n solo visible si hay resultados
71
  if 'semantic_result' in st.session_state and st.session_state.semantic_result is not None:
 
72
  export_button = st.button(
73
  semantic_t.get('export_button', 'Export Analysis'),
74
  key=f"semantic_export_{st.session_state.semantic_analysis_counter}",
75
  use_container_width=True
76
  )
77
  if export_button:
78
- pdf_buffer = export_user_interactions(st.session_state.username, 'semantic')
79
  st.download_button(
80
  label=semantic_t.get('download_pdf', 'Download PDF'),
81
- data=pdf_buffer,
82
  file_name="semantic_analysis.pdf",
83
  mime="application/pdf",
84
- key=f"semantic_download_{st.session_state.semantic_analysis_counter}"
 
85
  )
86
 
87
  st.markdown("---") # Separador
 
38
  semantic_t: Diccionario de traducciones sem谩nticas
39
  """
40
  try:
41
+ # Inicializar estados
42
  if 'semantic_analysis_counter' not in st.session_state:
43
  st.session_state.semantic_analysis_counter = 0
44
  if 'semantic_current_file' not in st.session_state:
 
46
  if 'semantic_page' not in st.session_state:
47
  st.session_state.semantic_page = 'semantic'
48
 
49
+ # Contenedor fijo para todos los controles
50
  with st.container():
51
  st.markdown("### Controls")
52
+
53
+ # File uploader
54
  uploaded_file = st.file_uploader(
55
  semantic_t.get('file_uploader', 'Upload a text file for analysis'),
56
  type=['txt'],
 
58
  on_change=lambda: setattr(st.session_state, 'semantic_current_file', uploaded_file)
59
  )
60
 
61
+ # Contenedor para botones alineados a la izquierda
62
+ left_col, mid_col, right_col = st.columns([1,4,1])
63
+ with left_col:
64
+ # Bot贸n de an谩lisis
65
  analyze_button = st.button(
66
  semantic_t.get('analyze_button', 'Analyze text'),
67
  key=f"semantic_analyze_button_{st.session_state.semantic_analysis_counter}",
 
69
  use_container_width=True
70
  )
71
 
72
+ # Bot贸n de exportaci贸n (si hay resultados)
73
  if 'semantic_result' in st.session_state and st.session_state.semantic_result is not None:
74
+ st.markdown("") # Espaciador
75
  export_button = st.button(
76
  semantic_t.get('export_button', 'Export Analysis'),
77
  key=f"semantic_export_{st.session_state.semantic_analysis_counter}",
78
  use_container_width=True
79
  )
80
  if export_button:
 
81
  st.download_button(
82
  label=semantic_t.get('download_pdf', 'Download PDF'),
83
+ data=export_user_interactions(st.session_state.username, 'semantic'),
84
  file_name="semantic_analysis.pdf",
85
  mime="application/pdf",
86
+ key=f"semantic_download_{st.session_state.semantic_analysis_counter}",
87
+ use_container_width=True
88
  )
89
 
90
  st.markdown("---") # Separador