Skip to content

feat(otomi normalizer)#19

Merged
umoqnier merged 8 commits intoElotlMX:masterfrom
paoinnesb:otomi-normalizer
Oct 10, 2024
Merged

feat(otomi normalizer)#19
umoqnier merged 8 commits intoElotlMX:masterfrom
paoinnesb:otomi-normalizer

Conversation

@paoinnesb
Copy link
Collaborator

add normalizer for Otomi with its lexc and att files. Restructure utils/fst/att and changes in makefile


name: Pull request
about:


Please include the next info:

  • No related issue
  • I have added the ortography.py for Otomi, following the convention of the Nahuatl normalizer. For this change, I also updated the Makefile, adding automation to create .att and .lexc files for the Otomi normalizer. I have restructured utils/fst/att, creating two folders (nahuatl and otomi), and added the respective orthographies for each language.
  • @Lguyogiro @umoqnier

…ructure utils/fst/att and changes in makefile
@Lguyogiro Lguyogiro self-requested a review September 20, 2024 23:30
Copy link
Member

@umoqnier umoqnier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dejo un par de comments pero en general se ve bastante bien. Buenos docstrings 💯 . Me queda duda si al final no agregamos mas tests y si corrieron los que existen para ver que todo este ok con el código existente que modificaron o que clase de pruebas hicieron para ver que no rompieran nada ❓ Si pueden agregar pantallazos a la descripción del PR para que quede documentado vendría joya :)

No mire demasiado los archivos .att o .lexc se los dejo a @Lguyogiro :p

_path_to_orig_fon = p

_ORIG_FON_FST = ATTFST(_path_to_orig_fon)
_available_orthographies = ['inali', 'otq', 'ots', "rfe"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creo que si es una variable global conviene que este en mayúsculas

Suggested change
_available_orthographies = ['inali', 'otq', 'ots', "rfe"]
_AVAILABLE_ORTHOGRAPHIES = ['inali', 'otq', 'ots', "rfe"]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listo 👍

Comment on lines +61 to +62
print(normalized_ort + " is not a supported orthography.")
print("Using 'inali' as orthography.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creo que esto podría ir con logs como un warning ¿no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya quedó como warning :)

Copy link
Collaborator

@Lguyogiro Lguyogiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, se ve muy bien. Antes de hacer el merge yo recomendaría que agreguen unos tests aquí.

#
DEFAULT_LANG_CODE = "ote"
SUPPORTED_LANG_CODES = ["ote"]
SUPPORTED_LANG_CODES = ["ote", "inali", "ots", "otq", "rfe"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

creo que esto puede ser un poco confuso porque se están mezclando códigos de la lengua (como "ote") con códigos referentes al sistema de ortografía. Creo que sería mejor cambiar el nombre de este variable o mover los códigos de las ortografías a otra lista. creo que con el Nahuatl hay algo como _available_orthographies aparte de las opciones de "language codes" o algo así.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debo mencionar que lo de los "LANG_CODES" es para cuando tenemos analizadores morfológicos para distintas variantes de una lengua.

@paoinnesb paoinnesb requested a review from Lguyogiro October 5, 2024 05:14
@paoinnesb
Copy link
Collaborator Author

paoinnesb commented Oct 5, 2024

Se hicieron los siguientes cambios

  • Agregar AVAILABLE_ORTHOGRAPHIES como constante en config.py y usarlo en ambos normalizadores (nahuatl y otomi), antes estaba como una variable dentro de cada orthography.py. Para el caso del los analizadores tenían un lang_code default por lo que también agregué un DEFAULT_ORTHOGRAPHY para los normalizadores dentro de config de igual manera
  • Encontré que el uso de logger.warn() ya es deprecated por lo que lo cambié por logger.warning dentro de los archivos orthography.py
  • Cambio de print() por logger.warning(). En el aviso de la ortografía por default que es usada
  • Cambio de path() por files(). Debido a que path quedó deprecated, lo hice en todos los archivos que encontré que usaran path()
  • Uso de open() cuando se abren los archivos para evitar warnings. Al correr los test en el caso de los analizadores morfológicos mandaban muchos warnings lo que hacía difícil ver cuáles eran los verdaderos errores, esto porque no se usaba la lectura de archivos con la función open() lo que ocasionaba que los archivos quedaran abiertos
  • Eliminación de null. En una parte de los test para el analizador morfologico del nahuatl se usaba null en vez de None, esto no permitía que el test pudiera ser ejecutado

Cambios faltantes:

  • Documentación para las normas del nahuatl
  • Test del otomí

@paoinnesb
Copy link
Collaborator Author

Se hicieron los siguientes cambios

  • Agregar AVAILABLE_ORTHOGRAPHIES como constante en config.py y usarlo en ambos normalizadores (nahuatl y otomi), antes estaba como una variable dentro de cada orthography.py. Para el caso del los analizadores tenían un lang_code default por lo que también agregué un DEFAULT_ORTHOGRAPHY para los normalizadores dentro de config de igual manera
  • Encontré que el uso de logger.warn() ya es deprecated por lo que lo cambié por logger.warning dentro de los archivos orthography.py
  • Cambio de print() por logger.warning(). En el aviso de la ortografía por default que es usada
  • Cambio de path() por files(). Debido a que path quedó deprecated, lo hice en todos los archivos que encontré que usaran path()
  • Uso de open() cuando se abren los archivos para evitar warnings. Al correr los test en el caso de los analizadores morfológicos mandaban muchos warnings lo que hacía difícil ver cuáles eran los verdaderos errores, esto porque no se usaba la lectura de archivos con la función open() lo que ocasionaba que los archivos quedaran abiertos
  • Eliminación de null. En una parte de los test para el analizador morfologico del nahuatl se usaba null en vez de None, esto no permitía que el test pudiera ser ejecutado

Cambios faltantes:

  • Documentación para las normas del nahuatl
  • Test del otomí
Screenshot 2024-10-06 at 7 26 20 p m Aquí está el screenshot que muestra que las pruebas corren, hay algunas fallas en la parte del analizador del nahuatl pero tengo la teoría que estas nunca han funcionado, ya que al correrlas había un error de sintaxis, eso quedó solucionado pero aún así no pasan

Copy link
Member

@umoqnier umoqnier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En general está bien. Dejé unos coments con sugerencias y dudas. Resolviendo esto de mi lado estaría ok

else:
if lang_code not in SUPPORTED_LANG_CODES:
logger.error("Unsupported language variant specified.")
#logger.error("Unsupported language variant specified.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¿Esto debería estar comentado?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no jeje, lo descomento

Comment on lines +56 to +57
_path_to_att_dir = pkg_resources.files("elotl.nahuatl.data").joinpath(f"{self.lang_code}.mor.att")
_path_to_tsv_dir = pkg_resources.files("elotl.nahuatl.data").joinpath(f"{self.lang_code}.mor.tsv")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

paoinnesb and others added 4 commits October 8, 2024 21:50
Co-authored-by: Diego Alberto Barriga Martínez <dbarriga@ciencias.unam.mx>
Co-authored-by: Diego Alberto Barriga Martínez <dbarriga@ciencias.unam.mx>
Co-authored-by: Diego Alberto Barriga Martínez <dbarriga@ciencias.unam.mx>
Copy link
Collaborator

@Lguyogiro Lguyogiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Lguyogiro
Copy link
Collaborator

Lguyogiro commented Oct 10, 2024

Aquí está el screenshot que muestra que las pruebas corren, hay algunas fallas en la parte del analizador del nahuatl pero tengo la teoría que estas nunca han funcionado, ya que al correrlas había un error de sintaxis, eso quedó solucionado pero aún así no pasan

Que yo me acuerde, sí funcionaban al principio pero ya se han metido muchos cambios desde que se establecieron y al parecer no siempre corríamos los tests jaja. cuando tenga tiempo me pongo a ver esto.

@umoqnier umoqnier merged commit 546b447 into ElotlMX:master Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants