AIdeaText commited on
Commit
f22513d
·
verified ·
1 Parent(s): 7e75701

Update modules/studentact/current_situation_interface.py

Browse files
modules/studentact/current_situation_interface.py CHANGED
@@ -81,16 +81,7 @@ def display_current_situation_interface(lang_code, nlp_models, t):
81
  """
82
  # Agregar logs para depuración
83
  logger.info(f"Idioma: {lang_code}")
84
- logger.info(f"CURRENT_SITUATION en t: {t.get('CURRENT_SITUATION', 'No existe')}")
85
- logger.info(f"Claves en CURRENT_SITUATION: {list(t.get('CURRENT_SITUATION', {}).keys())}")
86
-
87
- # Obtener traducciones de la situación actual
88
- current_situation_t = t.get('CURRENT_SITUATION', {})
89
-
90
- # Obtener traducciones para tipos de texto
91
- #text_types_translations = {}
92
- #if 'RECOMMENDATIONS' in t and lang_code in t['RECOMMENDATIONS']:
93
- # text_types_translations = t['RECOMMENDATIONS'][lang_code]['text_types']
94
 
95
  # Inicializar estados si no existen
96
  if 'text_input' not in st.session_state:
@@ -105,21 +96,20 @@ def display_current_situation_interface(lang_code, nlp_models, t):
105
  st.session_state.current_metrics = None
106
  if 'current_recommendations' not in st.session_state:
107
  st.session_state.current_recommendations = None
108
- ####################################################################################
109
- ####################################################################################
110
  try:
111
  # Container principal con dos columnas
112
  with st.container():
113
  input_col, results_col = st.columns([1,2])
114
 
115
  with input_col:
116
- # Text area con manejo de estado
117
  text_input = st.text_area(
118
  t.get('input_prompt', "Escribe o pega tu texto aquí:"),
119
  height=400,
120
- key="text_area",
121
  value=st.session_state.text_input,
122
- help="Este texto será analizado para darte recomendaciones personalizadas"
123
  )
124
 
125
  # Función para manejar cambios de texto
@@ -128,13 +118,13 @@ def display_current_situation_interface(lang_code, nlp_models, t):
128
  st.session_state.show_results = False
129
 
130
  if st.button(
131
- t.get('analyze_button', "Analizar mi escritura"),
132
  type="primary",
133
  disabled=not text_input.strip(),
134
  use_container_width=True,
135
  ):
136
  try:
137
- with st.spinner(t.get('processing', "Analizando...")):
138
  doc = nlp_models[lang_code](text_input)
139
  metrics = analyze_text_dimensions(doc)
140
 
@@ -154,37 +144,33 @@ def display_current_situation_interface(lang_code, nlp_models, t):
154
 
155
  except Exception as e:
156
  logger.error(f"Error en análisis: {str(e)}")
157
- st.error(t.get('analysis_error', "Error al analizar el texto"))
158
- #######################################################################################################
159
 
160
  # Mostrar resultados en la columna derecha
161
  with results_col:
162
  if st.session_state.show_results and st.session_state.current_metrics is not None:
163
- # Primero los radio buttons para tipo de texto
164
- st.markdown(f"### {current_situation_t.get('text_type_header', 'Tipo de texto')}")
165
 
166
  # Preparar opciones de tipos de texto con nombres traducidos
167
  text_type_options = {}
168
  for text_type_key in TEXT_TYPES.keys():
169
- if text_type_key in text_types_translations:
170
- text_type_options[text_type_key] = text_types_translations[text_type_key]
171
- else:
172
- # Fallback a nombres genéricos si no hay traducción
173
- default_names = {
174
- 'academic_article': 'Academic Article' if lang_code == 'en' else 'Артикул академічний' if lang_code == 'uk' else 'Artículo Académico',
175
- 'student_essay': 'Student Essay' if lang_code == 'en' else 'Студентське есе' if lang_code == 'uk' else 'Trabajo Universitario',
176
- 'general_communication': 'General Communication' if lang_code == 'en' else 'Загальна комунікація' if lang_code == 'uk' else 'Comunicación General'
177
- }
178
- text_type_options[text_type_key] = default_names.get(text_type_key, text_type_key)
179
 
180
  text_type = st.radio(
181
- label=current_situation_t.get('text_type_header', "Tipo de texto"),
182
  options=list(TEXT_TYPES.keys()),
183
  format_func=lambda x: text_type_options.get(x, x),
184
  horizontal=True,
185
  key="text_type_radio",
186
  label_visibility="collapsed",
187
- help=current_situation_t.get('text_type_help', "Selecciona el tipo de texto para ajustar los criterios de evaluación")
188
  )
189
 
190
  st.session_state.current_text_type = text_type
@@ -201,7 +187,7 @@ def display_current_situation_interface(lang_code, nlp_models, t):
201
  metrics=st.session_state.current_metrics,
202
  text_type=text_type,
203
  lang_code=lang_code,
204
- t=current_situation_t
205
  )
206
 
207
  # Mostrar recomendaciones en el segundo subtab
@@ -217,7 +203,7 @@ def display_current_situation_interface(lang_code, nlp_models, t):
217
 
218
  except Exception as e:
219
  logger.error(f"Error en interfaz principal: {str(e)}")
220
- st.error(current_situation_t.get('error_interface', "Ocurrió un error al cargar la interfaz"))
221
 
222
  #################################################################
223
  #################################################################
 
81
  """
82
  # Agregar logs para depuración
83
  logger.info(f"Idioma: {lang_code}")
84
+ logger.info(f"Claves en t: {list(t.keys())}")
 
 
 
 
 
 
 
 
 
85
 
86
  # Inicializar estados si no existen
87
  if 'text_input' not in st.session_state:
 
96
  st.session_state.current_metrics = None
97
  if 'current_recommendations' not in st.session_state:
98
  st.session_state.current_recommendations = None
99
+
 
100
  try:
101
  # Container principal con dos columnas
102
  with st.container():
103
  input_col, results_col = st.columns([1,2])
104
 
105
  with input_col:
106
+ # Text area con manejo de estado - usando t.get directamente
107
  text_input = st.text_area(
108
  t.get('input_prompt', "Escribe o pega tu texto aquí:"),
109
  height=400,
110
+ key=f"text_area_{lang_code}", # Clave única por idioma
111
  value=st.session_state.text_input,
112
+ help=t.get('help', "Este texto será analizado para darte recomendaciones personalizadas")
113
  )
114
 
115
  # Función para manejar cambios de texto
 
118
  st.session_state.show_results = False
119
 
120
  if st.button(
121
+ t.get('analyze_button', "Analizar mi escritura"), # Usando t.get directamente
122
  type="primary",
123
  disabled=not text_input.strip(),
124
  use_container_width=True,
125
  ):
126
  try:
127
+ with st.spinner(t.get('processing', "Analizando...")): # Usando t.get directamente
128
  doc = nlp_models[lang_code](text_input)
129
  metrics = analyze_text_dimensions(doc)
130
 
 
144
 
145
  except Exception as e:
146
  logger.error(f"Error en análisis: {str(e)}")
147
+ st.error(t.get('analysis_error', "Error al analizar el texto")) # Usando t.get directamente
 
148
 
149
  # Mostrar resultados en la columna derecha
150
  with results_col:
151
  if st.session_state.show_results and st.session_state.current_metrics is not None:
152
+ # Primero los radio buttons para tipo de texto - usando t.get directamente
153
+ st.markdown(f"### {t.get('text_type_header', 'Tipo de texto')}")
154
 
155
  # Preparar opciones de tipos de texto con nombres traducidos
156
  text_type_options = {}
157
  for text_type_key in TEXT_TYPES.keys():
158
+ # Fallback a nombres genéricos si no hay traducción
159
+ default_names = {
160
+ 'academic_article': 'Academic Article' if lang_code == 'en' else 'Артикул академічний' if lang_code == 'uk' else 'Artículo Académico',
161
+ 'student_essay': 'Student Essay' if lang_code == 'en' else 'Студентське есе' if lang_code == 'uk' else 'Trabajo Universitario',
162
+ 'general_communication': 'General Communication' if lang_code == 'en' else 'Загальна комунікація' if lang_code == 'uk' else 'Comunicación General'
163
+ }
164
+ text_type_options[text_type_key] = default_names.get(text_type_key, text_type_key)
 
 
 
165
 
166
  text_type = st.radio(
167
+ label=t.get('text_type_header', "Tipo de texto"), # Usando t.get directamente
168
  options=list(TEXT_TYPES.keys()),
169
  format_func=lambda x: text_type_options.get(x, x),
170
  horizontal=True,
171
  key="text_type_radio",
172
  label_visibility="collapsed",
173
+ help=t.get('text_type_help', "Selecciona el tipo de texto para ajustar los criterios de evaluación") # Usando t.get directamente
174
  )
175
 
176
  st.session_state.current_text_type = text_type
 
187
  metrics=st.session_state.current_metrics,
188
  text_type=text_type,
189
  lang_code=lang_code,
190
+ t=t # Pasar t directamente, no current_situation_t
191
  )
192
 
193
  # Mostrar recomendaciones en el segundo subtab
 
203
 
204
  except Exception as e:
205
  logger.error(f"Error en interfaz principal: {str(e)}")
206
+ st.error(t.get('error_interface', "Ocurrió un error al cargar la interfaz")) # Usando t.get directamente
207
 
208
  #################################################################
209
  #################################################################