Elixir GenFST

Build StatusHex.pmlicense

GenFST implements a generic finite state transducer with customizable rules expressed in a DSL.

A finite-state transducer (FST) is a finite-state machine with two memory tapes, following the terminology for Turing machines: an input tape and an output tape.

A FST will read a set of strings on the input tape and generates a set of relations on the output tape. An FST can be thought of as a translator or relater between strings in a set.

In morphological parsing, an example would be inputting a string of letters into the FST, the FST would then output a string of morphemes.

Example

Here we implement a simple morphological parser for English language. This morphological parser recognize different inflectional morphology of the verbs.

defmodule MorphologicalParser do
  use GenFST

  rule ["play", {"s", "^s"}]
  rule ["act", {"s", "^s"}]

end
assert MorphologicalParser.parse("acts") == "act^s"

For example if we pass the third-person singluar tense of the verb act, MorphologicalParser.parse("acts"), the morphological parser will output "act^s". The semantic of rule definition is given at rule/1.

Installation

The package can be installed by adding gen_fst to your list of dependencies in mix.exs:

def deps do
  [{:gen_fst, "~> 0.1.0"}]
end

Documentation

The docs for this project can be found at https://hexdocs.pm/gen_fst.