Skip to main content

A pure-python when needed, transparently natively accelerated if available, 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.3.3.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kfst-4.3.3-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kfst-4.3.3.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for kfst-4.3.3.tar.gz
Algorithm Hash digest
SHA256 a4af67d1604726f07f5d1fd5a17d3aae4e3d07f29055472a35bd32ff271ae75e
MD5 f2bcd19ffcdb877c71b45bddf75765a7
BLAKE2b-256 2402019179a0f758cb36beddacb44e350017975485e69c4f3d5ac54a5548af56

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kfst-4.3.3-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for kfst-4.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3f8df5d768bdae67390cc2b9a2aa67163d9e3d1740b39bc9646de70b74b1da2d
MD5 740198ef5169da90984866057a905883
BLAKE2b-256 101f5819392c356407386fbf9b0e981c4dfd0c171fd976c507a01ca06c6278e1

See more details on using hashes here.

Supported by

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