Project

voikko

0.0
The project is in a healthy, maintained state
Ruby bindings for libvoikko, the Finnish morphological analyser, via FFI.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 1.17
 Project Readme

ruby-voikko

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.

Requirements

  • Linux with libvoikko1 and the Finnish dictionary voikko-fi:

    sudo apt install libvoikko1 voikko-fi
  • Ruby 3.3 or newer.

Installation

gem 'voikko'

Usage

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"]
end

Voikko.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.

License

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.