AIdeaText commited on
Commit
6c85747
verified
1 Parent(s): e1b8d97

Update modules/morphosyntax/morphosyntax_interface.py

Browse files
modules/morphosyntax/morphosyntax_interface.py CHANGED
@@ -250,10 +250,10 @@ def display_morphosyntax_results(result, lang_code, t):
250
  }
251
  }
252
 
253
- for key, value in morph_translations[lang_code].items():
254
- morph_string = morph_string.replace(key, value)
255
- return morph_string
256
-
257
  # Definir el mapeo de columnas
258
  column_mapping = {
259
  'text': morpho_t.get('word', 'Word'),
@@ -266,12 +266,12 @@ def display_morphosyntax_results(result, lang_code, t):
266
  # Renombrar las columnas existentes
267
  morph_df = morph_df.rename(columns={col: new_name for col, new_name in column_mapping.items() if col in morph_df.columns})
268
 
269
- # Primero definimos las columnas con morpho_t
270
  cat_col = morpho_t.get('grammatical_category', 'Grammatical category')
271
  dep_col = morpho_t.get('dependency', 'Dependency')
272
  morph_col = morpho_t.get('morphology', 'Morphology')
273
 
274
- # Luego las usamos en las transformaciones
275
  morph_df[cat_col] = morph_df[cat_col].map(lambda x: POS_TRANSLATIONS[lang_code].get(x, x))
276
  morph_df[dep_col] = morph_df[dep_col].map(lambda x: dep_translations[lang_code].get(x, x))
277
  morph_df[morph_col] = morph_df[morph_col].apply(lambda x: translate_morph(x, lang_code))
@@ -286,22 +286,7 @@ def display_morphosyntax_results(result, lang_code, t):
286
  ]
287
  columns_to_display = [col for col in columns_to_display if col in morph_df.columns]
288
 
289
- # Mostrar el DataFrame
290
- st.dataframe(morph_df[columns_to_display])
291
-
292
- morph_df[t['morphology']] = morph_df[t['morphology']].apply(lambda x: translate_morph(x, lang_code))
293
-
294
- # Seleccionar y ordenar las columnas a mostrar
295
- columns_to_display = [
296
- morpho_t.get('word', 'Word'),
297
- morpho_t.get('lemma', 'Lemma'),
298
- morpho_t.get('grammatical_category', 'Grammatical category'),
299
- morpho_t.get('dependency', 'Dependency'),
300
- morpho_t.get('morphology', 'Morphology')
301
- ]
302
- columns_to_display = [col for col in columns_to_display if col in morph_df.columns]
303
-
304
- # Mostrar el DataFrame
305
  st.dataframe(morph_df[columns_to_display])
306
 
307
  # Mostrar diagramas de arco (c贸digo existente)
 
250
  }
251
  }
252
 
253
+ for key, value in morph_translations[lang_code].items():
254
+ morph_string = morph_string.replace(key, value)
255
+ return morph_string
256
+
257
  # Definir el mapeo de columnas
258
  column_mapping = {
259
  'text': morpho_t.get('word', 'Word'),
 
266
  # Renombrar las columnas existentes
267
  morph_df = morph_df.rename(columns={col: new_name for col, new_name in column_mapping.items() if col in morph_df.columns})
268
 
269
+ # Definir nombres de columnas traducidas
270
  cat_col = morpho_t.get('grammatical_category', 'Grammatical category')
271
  dep_col = morpho_t.get('dependency', 'Dependency')
272
  morph_col = morpho_t.get('morphology', 'Morphology')
273
 
274
+ # Aplicar traducciones
275
  morph_df[cat_col] = morph_df[cat_col].map(lambda x: POS_TRANSLATIONS[lang_code].get(x, x))
276
  morph_df[dep_col] = morph_df[dep_col].map(lambda x: dep_translations[lang_code].get(x, x))
277
  morph_df[morph_col] = morph_df[morph_col].apply(lambda x: translate_morph(x, lang_code))
 
286
  ]
287
  columns_to_display = [col for col in columns_to_display if col in morph_df.columns]
288
 
289
+ # Mostrar el DataFrame (solo una vez)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  st.dataframe(morph_df[columns_to_display])
291
 
292
  # Mostrar diagramas de arco (c贸digo existente)