Skip to content

About

Ruby bindings for libvoikko, the Finnish morphological analyser, via FFI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

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.

About

Ruby bindings for libvoikko, the Finnish morphological analyser, via FFI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages