Ruby bindings for libvoikko, the Finnish morphological analyser
that also powers Finnish spellchecking in LibreOffice. The gem is pure Ruby and calls the
system's libvoikko through FFI; the library and its Finnish dictionary come from your
distro's packages.
-
Linux with
libvoikko1and the Finnish dictionaryvoikko-fi:sudo apt install libvoikko1 voikko-fi
-
Ruby 3.3 or newer.
gem 'voikko'require 'voikko'
Voikko.open(language: 'fi') do |voikko|
kadulla = voikko.analyze('kadulla').first
kadulla.base_form #=> "katu"
kadulla.sijamuoto #=> "ulkoolento"
voikko.base_forms('voi') #=> ["voida", "voi"]
voikko.base_forms('HELSINGISSÄ') #=> ["Helsinki"]
# A compound, cut into its parts as written:
voikko.analyze('tietokoneella').first.morphemes.map(&:text) #=> ["tieto", "koneella"]
endVoikko.open closes the handle after the block; Voikko.new leaves that to #close.
require 'voikko' does not load libvoikko; the first Voikko.new does. So your tests can
build a Voikko::Analysis by hand on a machine without libvoikko.
The full API is documented on rubydoc.info.
MIT, see LICENSE. The gem ships no Voikko code or data: libvoikko
(MPL 1.1 / GPL 2+ / LGPL 2.1+) and voikko-fi (GPL 2) are installed and licensed separately
by your distro.