Analyze Finnish Poetry Computationally

Poetry is a complex genre of literature, and it is often something that we wouldn't expect computers to be able to understand. Poems play with the language by intentionally breaking its structure and by expressing meaning in figurative language such as metaphors. A lot of the expressive power of poetry lies in its ability of provoking certain imagery, certain emotions, in the reader. 😌 As it turns out, it is possible to analyze Finnish poetry automatically in Python. 😃

Analyzing Finnish Poetry

For computational poem analysis, a specialized library called FinMeter is needed. It can be installed easily with the following command.

pip3 install finmeter tensorflow
python3 -m finmeter.download

Syllables and Meter

FinMeter can easily divide words into syllables, i.e. hyphenate Finnish, and identify short and long syllables. The length of a syllable, together with the length of a verse, is a good indicator of the poetic foot the poem follows.

import finmeter
finmeter.syllables("kettu")
finmeter.is_short_syllable("su") 
finmeter.analyze_kalevala(u"Vesi vanhin voitehista\nJänö juoksi järveen")
>> ["ket", "tu"]
>> True
>> [{'base_rule': {'message': '', 'result': True}, 'verse': u'Vesi vanhin voitehista', 'normal_meter': True, 'style': {'alliteration': True, 'viskuri': True}}, {'base_rule': {'message': 'Not enough syllables', 'result': False}, 'verse': u'J\xe4n\xf6 juoksi j\xe4rveen', 'style': {'alliteration': True, 'viskuri': True}}]

Meaning and Sentiment Analysis

The library can analyze certain aspects of semantics in Finnish poetry, such as the level of concreteness of words, how many semantic fields a poem has and the sentiment of a verse of a poem.

from finmeter import semantics
semantics.concreteness("kissa") #From 1 to 5
semantics.semantic_clusters(["kissa", "koira", "näätä", "hauki", "vesi", "lemmikki", "puhelin", "tieto|kone", "toimisto"])
semantics.similarity_clusters(["koira", "kissa", "hevonen"], ["talo", "koti", "ovi"])

from finmeter import sentiment
sentiment.predict("Kaikki on tosi kivaa")

>> 4.615
>> [['koira', 'lemmikki', 'kissa', 'näätä'], ['vesi', 'hauki'], ['toimisto', 'tieto|kone', 'puhelin']]
>> 0.18099508
>> 2

The possible values for the Finnish sentiment analysis are -2 and -1 for strongly negative and negative and 2 and 1 for strongly positive and positive.

Metaphor

Interpreting metaphors is a task that is usually considered too difficult for a computer. However, FinMeter library can interpret Finnish metaphors easily by using word relatedness information.

Here is an example of how to interpret mies on susi by using the library.

from finmeter import metaphor
metaphor.interpret("mies", "susi", maximum=10)
>> {'A': [('yksinäinen', 0), ('nuori', 3)], 'Adv': [], 'V': [('raadella', 0), ('tappaa', 1), ('ampua', 2), ('liikkua', 2), ('kaataa', 4)], 'N': [('metsästäjä', 1), ('suu', 3), ('vaate', 4)], 'UNK': []}

The resulting interpretations are grouped by parts of speech. The numbers indicate the scores for the interpretations – the lower the better.

Cite

If you use FinMeter to analyze Finnish poetry, please remember to cite us as well. 😉

Mika Hämäläinen and Khalid Alnajjar, 2019. Let's FACE it. Finnish Poetry Generation with Aesthetics and Framing. In the Proceedings of The 12th International Conference on Natural Language Generation. pp. 290–300