Skip to content

gremid/sfst-transduce

Repository files navigation

sfst-transduce

Python bindings for SFST focusing on transducer usage

PyPI

A Python library providing bindings for the Stuttgart Finite State Transducer system with a focus on the usage of compiled and serialized transducers, excluding code for transducer development and testing, which reduces compile and runtime dependencies.

Should you need the SFST tools for transducer generation, please take a look at their homepage for installation and usage instructions.

Installation

sfst-transduce is available at PyPI:

pip install sfst-transduce

Usage

import sfst_transduce

# Create instance from compiled transducer
transducer = sfst_transduce.Transducer('path/to/fst.a')

# Analysis
analysis_results = transducer.analyse("easier")
# Returns ['easy<ADJ><comp>'] for example.

# Generate a string. results are a list of analysis.
generate_results = transducer.generate("easy<ADJ><comp>")
# Returns ['easier'] for example.

# Create instance from compiled transducer (compacted serialisation)
transducer = sfst_transduce.CompactTransducer('path/to/fst.ca')
# Activate output of aligned input and output layer
transducer.both_layers = True
# Analysis
transducer.analyse('easier')
# Returns ['easy:i<ADJ>:<><comp>:e<>:r'] for example.

Development

rm -rf build ; pip install -e '.[dev]'

Release

scripts/release $NEW_VERSION
git push && git push --tags

Credits

The SFST tools have been implemented by Helmut Schmid, Institute for Computational Linguistics, University of Stuttgart, Germany and they are available under the GNU public license version 2 or higher.

Please cite the following publication if you want to refer to the SFST tools:

Schmid, Helmut. "A programming language for finite state transducers." FSMNLP. Vol. 4002. 2005. pdf

This Python library is a fork of the excellent SFST adaptation by Santhosh Thottingal, changing the focus of the Python part.