AIdeaText commited on
Commit
1702aef
·
verified ·
1 Parent(s): af5fb81

Update modules/ui/ui.py

Browse files
Files changed (1) hide show
  1. modules/ui/ui.py +75 -8
modules/ui/ui.py CHANGED
@@ -562,7 +562,6 @@ def display_morphosyntax_analysis_interface(nlp_models, lang_code):
562
  'text': t['word'],
563
  'lemma': t['lemma'],
564
  'pos': t['grammatical_category'],
565
- 'tag': t['tag'],
566
  'dep': t['dependency'],
567
  'morph': t['morphology']
568
  }
@@ -570,15 +569,83 @@ def display_morphosyntax_analysis_interface(nlp_models, lang_code):
570
  # Renombrar las columnas existentes
571
  morph_df = morph_df.rename(columns={col: new_name for col, new_name in column_mapping.items() if col in morph_df.columns})
572
 
573
- # Seleccionar las columnas que existen en el DataFrame
574
- columns_to_display = [col for col in [t['word'], t['lemma'], t['grammatical_category'], t['tag'], t['dependency'], t['morphology']] if col in morph_df.columns]
575
 
576
- # Mostrar las columnas originales (para depuración)
577
- st.write("Columnas originales:", morph_df.columns.tolist())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
 
579
- # Seleccionar y mostrar el DataFrame
580
- morph_df = morph_df[columns_to_display]
581
- st.dataframe(morph_df)
 
 
 
 
 
582
 
583
  # Mostrar diagramas de arco (código existente)
584
  with st.expander(t['arc_diagram'], expanded=True):
 
562
  'text': t['word'],
563
  'lemma': t['lemma'],
564
  'pos': t['grammatical_category'],
 
565
  'dep': t['dependency'],
566
  'morph': t['morphology']
567
  }
 
569
  # Renombrar las columnas existentes
570
  morph_df = morph_df.rename(columns={col: new_name for col, new_name in column_mapping.items() if col in morph_df.columns})
571
 
572
+ # Traducir las categorías gramaticales
573
+ morph_df[t['grammatical_category']] = morph_df[t['grammatical_category']].map(lambda x: POS_TRANSLATIONS[lang_code].get(x, x))
574
 
575
+ # Traducir las dependencias
576
+ dep_translations = {
577
+ 'es': {
578
+ 'ROOT': 'RAÍZ', 'nsubj': 'sujeto nominal', 'obj': 'objeto', 'iobj': 'objeto indirecto',
579
+ 'csubj': 'sujeto clausal', 'ccomp': 'complemento clausal', 'xcomp': 'complemento clausal abierto',
580
+ 'obl': 'oblicuo', 'vocative': 'vocativo', 'expl': 'expletivo', 'dislocated': 'dislocado',
581
+ 'advcl': 'cláusula adverbial', 'advmod': 'modificador adverbial', 'discourse': 'discurso',
582
+ 'aux': 'auxiliar', 'cop': 'cópula', 'mark': 'marcador', 'nmod': 'modificador nominal',
583
+ 'appos': 'aposición', 'nummod': 'modificador numeral', 'acl': 'cláusula adjetiva',
584
+ 'amod': 'modificador adjetival', 'det': 'determinante', 'clf': 'clasificador',
585
+ 'case': 'caso', 'conj': 'conjunción', 'cc': 'coordinante', 'fixed': 'fijo',
586
+ 'flat': 'plano', 'compound': 'compuesto', 'list': 'lista', 'parataxis': 'parataxis',
587
+ 'orphan': 'huérfano', 'goeswith': 'va con', 'reparandum': 'reparación', 'punct': 'puntuación'
588
+ },
589
+ 'en': {
590
+ 'ROOT': 'ROOT', 'nsubj': 'nominal subject', 'obj': 'object', 'iobj': 'indirect object', 'csubj': 'clausal subject',
591
+ 'ccomp': 'clausal complement', 'xcomp': 'open clausal complement', 'obl': 'oblique', 'vocative': 'vocative', 'expl': 'expletive',
592
+ 'dislocated': 'dislocated', 'advcl': 'adverbial clause modifier', 'advmod': 'adverbial modifier', 'discourse': 'discourse element',
593
+ 'aux': 'auxiliary', 'cop': 'copula', 'mark': 'marker', 'nmod': 'nominal modifier', 'appos': 'appositional modifier', 'nummod': 'numeric modifier',
594
+ 'acl': 'clausal modifier of noun', 'amod': 'adjectival modifier', 'det': 'determiner', 'clf': 'classifier', 'case': 'case marking', 'conj': 'conjunct',
595
+ 'cc': 'coordinating conjunction', 'fixed': 'fixed multiword expression', 'flat': 'flat multiword expression', 'compound': 'compound',
596
+ 'list': 'list', 'parataxis': 'parataxis', 'orphan': 'orphan', 'goeswith': 'goes with', 'reparandum': 'reparandum', 'punct': 'punctuation'
597
+ },
598
+ 'fr': {
599
+ 'ROOT': 'RACINE', 'nsubj': 'sujet nominal', 'obj': 'objet', 'iobj': 'objet indirect', 'csubj': 'sujet phrastique',
600
+ 'ccomp': 'complément phrastique', 'xcomp': 'complément phrastique ouvert', 'obl': 'oblique', 'vocative': 'vocatif', 'expl': 'explétif',
601
+ 'dislocated': 'disloqué', 'advcl': 'clause adverbiale', 'advmod': 'modifieur adverbial', 'discourse': 'élément de discours',
602
+ 'aux': 'auxiliaire', 'cop': 'copule', 'mark': 'marqueur', 'nmod': 'modifieur nominal',
603
+ 'appos': 'apposition', 'nummod': 'modifieur numéral', 'acl': 'clause relative', 'amod': 'modifieur adjectival', 'det': 'déterminant',
604
+ 'clf': 'classificateur', 'case': 'marqueur de cas', 'conj': 'conjonction', 'cc': 'coordination', 'fixed': 'expression figée',
605
+ 'flat': 'construction plate', 'compound': 'composé', 'list': 'liste', 'parataxis': 'parataxe', 'orphan': 'orphelin', 'goeswith': 'va avec',
606
+ 'reparandum': 'réparation', 'punct': 'ponctuation'
607
+ }
608
+ }
609
+ morph_df[t['dependency']] = morph_df[t['dependency']].map(lambda x: dep_translations[lang_code].get(x, x))
610
+
611
+ # Traducir la morfología
612
+ def translate_morph(morph_string, lang_code):
613
+ morph_translations = {
614
+ 'es': {
615
+ 'Gender': 'Género', 'Number': 'Número', 'Case': 'Caso', 'Definite': 'Definido',
616
+ 'PronType': 'Tipo de Pronombre', 'Person': 'Persona', 'Mood': 'Modo',
617
+ 'Tense': 'Tiempo', 'VerbForm': 'Forma Verbal', 'Voice': 'Voz',
618
+ 'Fem': 'Femenino', 'Masc': 'Masculino', 'Sing': 'Singular', 'Plur': 'Plural',
619
+ 'Ind': 'Indicativo', 'Sub': 'Subjuntivo', 'Imp': 'Imperativo', 'Inf': 'Infinitivo',
620
+ 'Part': 'Participio', 'Ger': 'Gerundio', 'Pres': 'Presente', 'Past': 'Pasado',
621
+ 'Fut': 'Futuro', 'Perf': 'Perfecto', 'Imp': 'Imperfecto'
622
+ },
623
+ 'en': {
624
+ 'Gender': 'Gender', 'Number': 'Number', 'Case': 'Case', 'Definite': 'Definite', 'PronType': 'Pronoun Type',
625
+ 'Person': 'Person', 'Mood': 'Mood', 'Tense': 'Tense', 'VerbForm': 'Verb Form', 'Voice': 'Voice', 'Fem': 'Feminine',
626
+ 'Masc': 'Masculine', 'Sing': 'Singular', 'Plur': 'Plural', 'Ind': 'Indicative', 'Sub': 'Subjunctive', 'Imp': 'Imperative',
627
+ 'Inf': 'Infinitive', 'Part': 'Participle', 'Ger': 'Gerund', 'Pres': 'Present', 'Past': 'Past', 'Fut': 'Future', 'Perf': 'Perfect',
628
+ 'Imp': 'Imperfect'
629
+ },
630
+ 'fr': {
631
+ 'Gender': 'Genre', 'Number': 'Nombre', 'Case': 'Cas', 'Definite': 'Défini', 'PronType': 'Type de Pronom', 'Person': 'Personne',
632
+ 'Mood': 'Mode', 'Tense': 'Temps', 'VerbForm': 'Forme Verbale', 'Voice': 'Voix', 'Fem': 'Féminin', 'Masc': 'Masculin', 'Sing': 'Singulier',
633
+ 'Plur': 'Pluriel', 'Ind': 'Indicatif', 'Sub': 'Subjonctif', 'Imp': 'Impératif', 'Inf': 'Infinitif', 'Part': 'Participe', 'Ger': 'Gérondif',
634
+ 'Pres': 'Présent', 'Past': 'Passé', 'Fut': 'Futur', 'Perf': 'Parfait', 'Imp': 'Imparfait'
635
+ }
636
+ }
637
+ for key, value in morph_translations[lang_code].items():
638
+ morph_string = morph_string.replace(key, value)
639
+ return morph_string
640
 
641
+ morph_df[t['morphology']] = morph_df[t['morphology']].apply(lambda x: translate_morph(x, lang_code))
642
+
643
+ # Seleccionar y ordenar las columnas a mostrar
644
+ columns_to_display = [t['word'], t['lemma'], t['grammatical_category'], t['dependency'], t['morphology']]
645
+ columns_to_display = [col for col in columns_to_display if col in morph_df.columns]
646
+
647
+ # Mostrar el DataFrame
648
+ st.dataframe(morph_df[columns_to_display])
649
 
650
  # Mostrar diagramas de arco (código existente)
651
  with st.expander(t['arc_diagram'], expanded=True):