How to use Omorfi for Finnish morphology

Omorfi is inarguably an amazing tool for processing Finnish morphology both in analysis and generation. However, using it might be quite a challenge for the users who are not too (H)FST savvy. 😅That is one of the motivations for my UralicNLP library the purpose of which is to provide an easy Python interface for a multitude NLP tools for Uralic languages.

Getting things ready

First, you will need to install UralicNLP like so:

sudo pip install uralicNLP

Next, run the following python script to download the Finnish model

from uralicNLP import uralicApi"fin")

Now you have everything ready to use Omorfi in Python. ☺️

Analysing Finnish morphology

You can use the analyze function provided in uralicApi to analyse a given word morphologically.

from uralicNLP import uralicApi
uralicApi.analyze("hattunikin", "fin")
>> (('hattu+N+Pl+Nom+PxSg1+Foc/kin', 0.0), ('hattu+N+Sg+Gen+PxSg1+Foc/kin', 0.0), ('hattu+N+Sg+Nom+PxSg1+Foc/kin', 0.0))

For hattu, Omorfi will produce the correct readings as it being in genitive or nominative in singular or in nominative in plural. The numbers at the end of each analysis are weights, however, weights are currently not implemented in Omorfi.

Inflecting Finnish words

Omorfi can also be used in generation of surface forms given an abstract morphological representation. This generation is also known as morphological inflection.

from uralicNLP import uralicApi
uralicApi.generate("hattu+N+Sg+Abl", "fin")
>> (('hatulta', 0.0),)

This inflects the word hattu correctly in ablative. You can use the analyze function on different word forms to see what the morphology looks like for generation.

If you are more interested in inflecting full sentences instead of individual words, you might want to look at my syntax maker tutorial.

Don't forget to cite

If you use Omorfi and UralicNLP in a scientific publication, please remember to cite them. 🙂

For UralicNLP, use

Hämäläinen, Mika. (2018). UralicNLP (Version v1.0). Zenodo.

For Omorfi, use

Pirinen, Tommi A ; Listenmaa, Inari ; Johnson, Ryan ; Tyers, Francis M. ; Kuokkala, Juha Open morphology of Finnish, (2017) PID:

Related Post