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-1.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

kfst-1.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for kfst-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5032cecfc8ceb33e210287d3be7c6b773006123764112451c73746344bfba919
MD5 0abb12eedc7078c04d1b14f743f0b5eb
BLAKE2b-256 7d6c5d2f8f56a510e722611fc1d7ac18ecef4f8484fcd52b123eb8efb4faa1f2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for kfst-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf716f9da88241e3d8ab63bea8c6573cfae1928d6080b2ca6eaa5107b0283ef0
MD5 e2a8db211b2d43952e3fce7fe968f83a
BLAKE2b-256 6b09d102edd8bb1436e6ed5b1b77a7923dea8da2af8eb5cd14529aac9e4d1d6d

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