Update modules/morphosyntax/morphosyntax_interface.py
Browse files
modules/morphosyntax/morphosyntax_interface.py
CHANGED
@@ -226,48 +226,46 @@ def display_morphosyntax_results(result, lang_code, t):
|
|
226 |
}
|
227 |
}
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
'
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
'
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
'
|
252 |
-
'Gender': 'Genre', 'Number': 'Nombre', 'Case': 'Cas', 'Definite': 'Défini', 'PronType': 'Type de Pronom',
|
253 |
-
'Person': 'Personne', 'Mood': 'Mode', 'Tense': 'Temps', 'VerbForm': 'Forme Verbale', 'Voice': 'Voix',
|
254 |
-
'Fem': 'Féminin', 'Masc': 'Masculin', 'Sing': 'Singulier', 'Plur': 'Pluriel', 'Ind': 'Indicatif',
|
255 |
-
'Sub': 'Subjonctif', 'Imp': 'Impératif', 'Inf': 'Infinitif', 'Part': 'Participe',
|
256 |
-
'Ger': 'Gérondif', 'Pres': 'Présent', 'Past': 'Passé', 'Fut': 'Futur', 'Perf': 'Parfait', 'Imp': 'Imparfait'
|
257 |
-
}
|
258 |
}
|
259 |
-
|
260 |
-
for key, value in morph_translations[lang_code].items():
|
261 |
-
morph_string = morph_string.replace(key, value)
|
262 |
-
return morph_string
|
263 |
-
|
264 |
-
# 4. Aplicar traducciones a las columnas originales antes de renombrarlas
|
265 |
-
morph_df['morph'] = morph_df['morph'].apply(lambda x: translate_morph(x, lang_code))
|
266 |
-
#morph_df['dep'] = morph_df['dep'].map(lambda x: dep_translations[lang_code].get(x, x))
|
267 |
-
#morph_df['morph'] = morph_df['morph'].apply(lambda x: translate_morph(x, lang_code))
|
268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
|
270 |
-
# 5.
|
271 |
column_mapping = {
|
272 |
'text': t['word'],
|
273 |
'lemma': t['lemma'],
|
@@ -279,7 +277,7 @@ def display_morphosyntax_results(result, lang_code, t):
|
|
279 |
# 6. Aplicar el renombrado
|
280 |
morph_df = morph_df.rename(columns=column_mapping)
|
281 |
|
282 |
-
# 7. Mostrar el DataFrame
|
283 |
st.dataframe(morph_df)
|
284 |
|
285 |
|
|
|
226 |
}
|
227 |
}
|
228 |
|
229 |
+
morph_translations = {
|
230 |
+
'es': {
|
231 |
+
'Gender': 'Género', 'Number': 'Número', 'Case': 'Caso', 'Definite': 'Definido',
|
232 |
+
'PronType': 'Tipo de Pronombre', 'Person': 'Persona', 'Mood': 'Modo',
|
233 |
+
'Tense': 'Tiempo', 'VerbForm': 'Forma Verbal', 'Voice': 'Voz',
|
234 |
+
'Fem': 'Femenino', 'Masc': 'Masculino', 'Sing': 'Singular', 'Plur': 'Plural',
|
235 |
+
'Ind': 'Indicativo', 'Sub': 'Subjuntivo', 'Imp': 'Imperativo', 'Inf': 'Infinitivo',
|
236 |
+
'Part': 'Participio', 'Ger': 'Gerundio', 'Pres': 'Presente', 'Past': 'Pasado',
|
237 |
+
'Fut': 'Futuro', 'Perf': 'Perfecto', 'Imp': 'Imperfecto'
|
238 |
+
},
|
239 |
+
'en': {
|
240 |
+
'Gender': 'Gender', 'Number': 'Number', 'Case': 'Case', 'Definite': 'Definite', 'PronType': 'Pronoun Type', 'Person': 'Person',
|
241 |
+
'Mood': 'Mood', 'Tense': 'Tense', 'VerbForm': 'Verb Form', 'Voice': 'Voice',
|
242 |
+
'Fem': 'Feminine', 'Masc': 'Masculine', 'Sing': 'Singular', 'Plur': 'Plural', 'Ind': 'Indicative',
|
243 |
+
'Sub': 'Subjunctive', 'Imp': 'Imperative', 'Inf': 'Infinitive', 'Part': 'Participle',
|
244 |
+
'Ger': 'Gerund', 'Pres': 'Present', 'Past': 'Past', 'Fut': 'Future', 'Perf': 'Perfect', 'Imp': 'Imperfect'
|
245 |
+
},
|
246 |
+
'fr': {
|
247 |
+
'Gender': 'Genre', 'Number': 'Nombre', 'Case': 'Cas', 'Definite': 'Défini', 'PronType': 'Type de Pronom',
|
248 |
+
'Person': 'Personne', 'Mood': 'Mode', 'Tense': 'Temps', 'VerbForm': 'Forme Verbale', 'Voice': 'Voix',
|
249 |
+
'Fem': 'Féminin', 'Masc': 'Masculin', 'Sing': 'Singulier', 'Plur': 'Pluriel', 'Ind': 'Indicatif',
|
250 |
+
'Sub': 'Subjonctif', 'Imp': 'Impératif', 'Inf': 'Infinitif', 'Part': 'Participe',
|
251 |
+
'Ger': 'Gérondif', 'Pres': 'Présent', 'Past': 'Passé', 'Fut': 'Futur', 'Perf': 'Parfait', 'Imp': 'Imparfait'
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
}
|
253 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
|
255 |
+
##############################
|
256 |
+
|
257 |
+
# 3. Definir la función de traducción de morfología
|
258 |
+
def translate_morph(morph_string):
|
259 |
+
for key, value in morph_translations[lang_code].items():
|
260 |
+
morph_string = morph_string.replace(key, value)
|
261 |
+
return morph_string
|
262 |
+
|
263 |
+
# 4. Aplicar todas las traducciones al contenido
|
264 |
+
morph_df['pos'] = morph_df['pos'].map(lambda x: POS_TRANSLATIONS[lang_code].get(x, x))
|
265 |
+
morph_df['dep'] = morph_df['dep'].map(lambda x: dep_translations[lang_code].get(x, x))
|
266 |
+
morph_df['morph'] = morph_df['morph'].apply(translate_morph)
|
267 |
|
268 |
+
# 5. Renombrar las columnas usando las traducciones de la interfaz
|
269 |
column_mapping = {
|
270 |
'text': t['word'],
|
271 |
'lemma': t['lemma'],
|
|
|
277 |
# 6. Aplicar el renombrado
|
278 |
morph_df = morph_df.rename(columns=column_mapping)
|
279 |
|
280 |
+
# 7. Mostrar el DataFrame
|
281 |
st.dataframe(morph_df)
|
282 |
|
283 |
|