Skip to content
Ricard Marxer edited this page Dec 1, 2015 · 5 revisions

Contributing to pyfst

Contributions to pyfst are welcome!

Development pipeline

To allow easy installation, the setup.py script does not require Cython and compiles the extension directly from the fst.cpp file.

Additionaly, to get around the lack of templates in Python, the Cython code (*.{pyx,pxd}) is itself generated from a templated version (*.tpl) of the code using mustache (using the commandline tool distributed with the Ruby implementation of mustache).

The steps to run to produce after modifying the code are:

cd fst
cat types.yml | mustache - _fst.pyx.tpl > _fst.pyx
cat types.yml | mustache - libfst.pxd.tpl > libfst.pxd
cython --cplus _fst.pyx

Notes

If you do not have OpenFST in your system path, you need to specify for the compiler where are the OpenFST headers and shared libraries. One possible solution is described below.

export FSTDIR=/your/path/to/fst/dir/containing/include/and/lib
export CPLUS_INCLUDE_PATH=$FSTDIR/include:$CPLUS_INCLUDE_PATH
export LIBRARY_PATH=$FSTDIR/lib:$FSTDIR/lib/fst:$LIBRARY_PATH
# This is necessary for using the library not the compilation itself
export LD_LIBRARY_PATH=$FSTDIR/lib:$FSTDIR/lib/fst:$LIBRARY_PATH:$LD_LIBRARY_PATH
pushd fst  # Directory with Cython and Python code
cat types.yml | mustache - _fst.pyx.tpl > _fst.pyx
cat types.yml | mustache - libfst.pxd.tpl > libfst.pxd
cython --cplus _fst.pyx
popd # back to setup.py directory
# Creates _fst.so which you can access by importing fst
python setup.py build_ext --inplace
python -c "import fst"

TODO list

pyfst is not a complete wrapper of the OpenFST API.

On the short term, here are operations which could be added:

  • StateMap
  • Closure with CLOSURE_PLUS
  • Decode / Encode
  • EpsNormalize
  • Push
  • RandEquivalent
  • RandGen
  • Replace
  • Reweight
  • Synchronize
  • Verify

On the long term, it could be useful to support other types of weights/arcs/transducers but this is default because of the lack of templates in Python/Cython.

Clone this wiki locally