keinontolibrary

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

How it works — rules, corpus, and verification →

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.

Read why Finnish is hard →

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.