Skip to main content

A pure-python finite state transducer library

Project description

KFST

KFST is a finite state transducer library written in pure Python. It supports reading transducers from AT&T tabular format files and its own binary format. In addition to standard features, it also supports flag diacritics.

The intended use case is to use KFST in environments in which native libraries like HFST cannot be installed.

Installation

KFST is available on PyPI and can be installed with pip:

pip install kfst

Usage

In this example, we assume that you have a transducer stored in the file my-transducer.att. You can easily create such file using the HFST toolkit:

hfst-fst2txt -f att my-transducer.hfst > my-transducer.att

# if you want a kfst file:
python -m kfst.convert my-transducer.att my-transducer.kfst

Reading transducers

Transducers can be read from AT&T tabular format files using the read_att_file function, and the KFST binary format using the read_kfst_file function:

from kfst import FST

fst = FST.read_att_file("my-transducer.att")
# or
fst = FST.read_kfst_file("my-transducer.kfst")

Using the transducer

To run the transducer, use the lookup method, which returns a list of tuples of the form (output, weight) sorted by weight:

fst.lookup("foo")

License

KFST is licensed under the GNU LGPL version 3 or later. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kfst-4.0.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

kfst-4.0.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file kfst-4.0.0.tar.gz.

File metadata

  • Download URL: kfst-4.0.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for kfst-4.0.0.tar.gz
Algorithm Hash digest
SHA256 a5c53dfc32a07764d35966b99626d78ddbdf47251f568a5b2f2f8603ff7f498e
MD5 9a040c84bfa0b5d4f6d73c3b4e79b141
BLAKE2b-256 53e6e601542b9d266ae7a872bdd85d8a01711d10b7a9bf4be2c90d8479098a7e

See more details on using hashes here.

File details

Details for the file kfst-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: kfst-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for kfst-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 857977262558268fccd7767e952bb11d488ed8bd8a466c33655299d47b060ea5
MD5 1dcb734bf3be5df5409bc25d7b52b9fa
BLAKE2b-256 e4c2f33a8213c85d120a237e33b0e1709715e067e4bcc72bbbb9e869554247c9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page