finmeter

Tools for assessing Finnish poetry: rhymes, meter, hyphenation of Finnish and so on.

https://github.com/mikahama/finmeter

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.9%) to scientific vocabulary

Keywords

aesthetic-evaluation computational-creativity finnish hyphenation kalevala-meter metaphors nlp poetry semantics sentiment syllables

Keywords from Contributors

conll-u constraint-grammar dutch french fst german large-language-model lemmatizer moksha morphological-analysis
Last synced: 6 months ago · JSON representation ·

Repository

Tools for assessing Finnish poetry: rhymes, meter, hyphenation of Finnish and so on.

Basic Info
Statistics
  • Stars: 13
  • Watchers: 3
  • Forks: 1
  • Open Issues: 0
  • Releases: 4
Topics
aesthetic-evaluation computational-creativity finnish hyphenation kalevala-meter metaphors nlp poetry semantics sentiment syllables
Created over 6 years ago · Last pushed about 2 years ago
Metadata Files
Readme Funding License Citation

README.md

FinMeter

DOI DOI

FinMeter is a library for analyzing poetry in Finnish. It handles typical rhyming such as alliteration, assonance and consonance, Japanese meters and Kalevala meter. It can also be used to hyphenate Finnish and analyse meter. In addition, it can do semantic clustering, metaphor interpretation, concreteness scoring and sentiment analysis

pip install finmeter

If you use the methods relating to semantics, metaphors and sentiment, you will need to run:

python3 -m finmeter.download 

Sentiment analysis requires tensorflow (tested on 1.9.0 and numpy 1.16.4).

Hyphenation

Finnish words can be divided into syllables like so

import finmeter
finmeter.hyphenate("hattu")
>> hat-tu
finmeter.syllables("hattu")
>> ["hat", "tu"]
finmeter.count_sentence_syllables("kissa juoksi")
>> 4

Rhyming

FinMeter can be used to check whether two words rhyme

import finmeter
finmeter.assonance("ladata", "ravata") #True
finmeter.consonance("kettu", "katti") #True
finmeter.full_rhyme("pallolla", "kallolla") #True
finmeter.alliteration("voi", "vehn") #True

Syllabic meters

Meters based on the number of syllables can be assessed by FinMeter

import finmeter
finmeter.list_possible_meters()
>> ['tanka', 'kalevala', 'katauta', 'sedooka', 'bussokusekika', 'haiku', 'chooka']
finmeter.assess_meter(u"kissa juoksee\nkovaa juoksee", "haiku")
>> {'verse_results': [(False, '4/5'), (False, '4/7')], 'poem_length_error': '2/3', 'poem_length_ok': False}

The result is a dictionary cointaining information about the meter for each verse in "verse results" and about the overall length in "poemlengtherror". Note: For Kalevala you should use analyze_kalevala instead.

Kalevala meter

Kalevala meter functionality takes the poetic foot into account and accepts verses of upto 10 syllables providing that certain poetic rules are met. In addition, the method assess other features important in Kalevala

import finmeter
finmeter.analyze_kalevala(u"Vesi vanhin voitehista\nJn juoksi jrveen")
>> [{'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}}]

The method returns a list of analysis results for each verse. If base_rule is True, it means that the verse follows the Kalevala meter, both in syllables and in foot.

Syllable length

To check if a syllable is short, use the following method

import finmeter
finmeter.is_short_syllable("tu") 
>> True

Semantics

The library has a variety of different functions realted to semantics

Concreteness

from finmeter import semantics

semantics.concreteness("kissa")
>> 4.615
semantics.is_concrete("kissa")
>> True

The former method outputs True if the concreteness of the word is equal or greater than 3. The latter method outputs a concreteness score from 1 to 5. Both of the methods will return None for out of vocabulary words.

Semantic clusters

from finmeter import semantics

semantics.semantic_clusters(["kissa", "koira", "nt", "hauki", "vesi", "lemmikki", "puhelin", "tieto|kone", "toimisto"])
>> [['koira', 'lemmikki', 'kissa', 'nt'], ['vesi', 'hauki'], ['toimisto', 'tieto|kone', 'puhelin']]
semantics.similarity_clusters(["koira", "kissa", "hevonen"], ["talo", "koti", "ovi"])
>> 0.18099508
semantics.cluster_centroid(["koira", "kissa", "hevonen"])
>> [-5.84886856e-02 -1.10119150e-03 -3.40119563e-03......]

The library can be used to cluster words together into semantic clusters and to assess the similarity of two word clusters.

Sentiment

The library provides a somewhat functional sentiment analysis, but I wouldn't hold my breath.

from finmeter import sentiment
sentiment.predict("Olipa kakkainen leffa")
>> -2
sentiment.predict("Kaikki on tosi kivaa")
>> 2

The possible values are -2 for strongly negative, -1 for negative, 1 for positive and 2 for strongly positive.

Metaphors

The library can give interpretations for metaphors. The lower the value, the more likely the interpretation. Example for mies on susi

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

maximum is an optional parameter to limit the number of interpretations. If you do not need POS tagging, you can pass pos_tags=False.

It is also possible to assess how metaphorical a tenor and vehicle candidates are in a given sentence (tuli leiskuu kuin thti taivaalla):

from finmeter import metaphor
metaphor.metaphoricity("tuli", "thti", ["tuli", "leiskua", "kuin", "thti", "taivas"])
>> 38.90

The score indicates how metaphorical the two words are given a context. NB the sentence has to be tokenized and lemmatized.

Cite

If you use this library, cite the following publication

Mika Hmlinen 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. pages 290-300

Owner

  • Name: Mika Hämäläinen
  • Login: mikahama
  • Kind: user
  • Location: Helsinki
  • Company: Fly for Points

PhD in NLP. Currently working at Metropolia University of Applied Sciences as an AI manager.

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: FinMeter
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Mika
    family-names: Hämäläinen
  - given-names: Khalid
    family-names: Alnajjar
identifiers:
  - type: doi
    value: 10.5281/zenodo.3474018
    description: Zenodo
repository-code: 'https://github.com/mikahama/finmeter'
date-released: '2019-10-05'
preferred-citation:
  type: article
  authors:
  - family-names: "Hämäläinen"
    given-names: "Mika"
  - family-names: "Alnajjar"
    given-names: "Khalid"
  journal: "the Proceedings of The 12th International Conference on Natural Language Generation"
  title: "Let's FACE it. Finnish Poetry Generation with Aesthetics and Framing"
  year: 2019

GitHub Events

Total
  • Watch event: 2
Last Year
  • Watch event: 2

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 24
  • Total Committers: 5
  • Avg Commits per committer: 4.8
  • Development Distribution Score (DDS): 0.583
Past Year
  • Commits: 3
  • Committers: 2
  • Avg Commits per committer: 1.5
  • Development Distribution Score (DDS): 0.333
Top Committers
Name Email Commits
Mika Hämäläinen m****a 10
Hämäläinen, Mika K m****n@h****i 9
Mika Hämäläinen m****a@r****m 3
Khalid Alnajjar d****a@g****m 1
Mika Hämäläinen s****s@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 36 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 3
  • Total maintainers: 1
pypi.org: finmeter

Hyphenator and poem analysis for Finnish

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 36 Last month
Rankings
Dependent packages count: 10.1%
Stargazers count: 16.6%
Dependent repos count: 21.5%
Average: 22.0%
Forks count: 22.6%
Downloads: 39.3%
Maintainers (1)
Last synced: 6 months ago

Dependencies

setup.py pypi
  • unidecode *