A Rust library that declines Finnish nouns.
Give it a noun lemma and a case; it returns the inflected form(s). Data-backed — precomputed forms from a reference corpus collected over three years — with a rule-based fallback over the Kotus declension classes.
decline("hevonen", Number::Plural, Case::Inessive) -> ["hevosissa"]
What it does
- Declines every declinable Kotus 2024 nominal. 100% coverage of declinable nominal rows, each form independently verified. All 15 cases, both numbers, multi-paradigm homonyms.
- Rules + corpus + registry, not a lookup table. A rule generator handles the base Kotus classes 1–49 with consonant gradation (~98% rule↔corpus agreement); the compound classes tn 50–51 inflect through their components; and a verified exception registry plus overrides cover the irregulars the rules don't. The whole Kotus 1–51 nominal range is in scope.
- Embeddable, in the shape you need. A Rust crate, a CLI, an HTTP service, and a single-binary container under 10 MB. Nominals only (substantives, adjectives, numerals, pronouns); verbs are out of scope.
The hard cases it gets right
Finnish declension is full of traps. These are the words people use to trip a naive table — each form below is verified.
vaaka → vaa'an, vaaoissa
k-deletion between like vowels is written with an apostrophe in the singular, but the plural rounds the vowel and drops it.
afääri → afääriä · country → countrya
Vowel harmony follows the last strong vowel; in English loans y doesn't count as a front vowel.
jokin → jossakin · kukaan → kenenkään
Some pronouns inflect the clitic on the inside; others keep it at the end
(kumpikin → kummankin).
kuka → kenet
The accusative of kuka is suppletive — not *kukan.
taika → taian
Not *tajan: taika isn't the compound t + aika.
Compound detection requires at least a two-letter first part.
antigeeni → antigeenissä
A compound's harmony follows its last part, even when the spelling shows a back vowel earlier.
Quickstart
As a Rust crate
# Cargo.toml — crates.io publish is coming; until then, depend on git:
keinontolibrary = { git = "https://github.com/timokoola/keinontolibrary" }
use keinontolibrary_core::{Case, Number};
use keinontolibrary_data::build_engine;
let bundle = build_engine("data/artifact/keinontolibrary.bin", "data/overlay.jsonl")?;
let forms = bundle.engine.decline("hevonen", Number::Plural, Case::Inessive)?;
assert_eq!(forms.primary(), Some("hevosissa"));
From the terminal
cargo install --path crates/keinontolibrary-cli
keinontolibrary decline hevonen --number plural --case inessive
keinontolibrary table talo # the full paradigm
keinontolibrary table parfait --format csv
As an HTTP service
docker run -p 8080:8080 keinontolibrary
curl 'localhost:8080/decline?word=hevonen&number=plural&case=inessive'
curl 'localhost:8080/paradigm?word=talo' # full table as JSON
Full guides: embed, CLI, HTTP, build the artifact, contribute →
See it in the wild
humalapaikallissija.com is a toy built on this library: type any Finnish noun and get its forms, with a full declension table per word. If you want to browse declensions rather than embed them, start there.