Project

ruby-sfst

0.01
No commit activity in last 3 years
No release in over 3 years
A wrapper for the Stuttgart Finite State Transducer Tools (SFST).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 0.11
~> 12.3
~> 3.7
~> 0.15
~> 0.9
 Project Readme

ruby-sfst

ruby-sfst is a wrapper for the Stuttgart Finite State Transducer Tools (SFST).

The wrapper is based on SFST 1.4.7e. See http://www.cis.uni-muenchen.de/~schmid/tools/SFST/ for details on how to obtain SFST and how to write SFST transducers.

Requires Ruby 2.4 or greater.

Installation

gem install ruby-sfst

Usage

If you have the following compiled as test.a

ALPHABET = [a-z]
$test$ = ({bar}:{foo} | {baz}:{foo})
$test$

it can be used like this:

fst = SFST::RegularTransducer.new("test.a")
fst.analyse('foo')
# => ['bar', 'baz']
fst.accepted_analysis?('foo')
# => true
fst.generate('bar')
# => ['foo']
fst.accepted_generating?('bar')
# => true
fst.generate_language { |f| p f }
# [["b", "f"], ["a", "o"], ["z", "o"]]
# [["b", "f"], ["a", "o"], ["r", "o"]]

You can also compile an SFST file. This requires the SFST tools to be installed and available on the current search path.

SFST::compile("test.fst", "test.a", :compact => true)

Currently, ruby-sfst only supports simple compilation, analysis and generation using regular and compact transducers. It also only supports UTF-8.

Development

The project is hosted on github on http://github.com/mlj/ruby-sfst.

License

As ruby-sfst includes parts of the SFST code, the wrapper inherits the GPL2 license of the SFST project.