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

Uploaded Source

Built Distribution

kfst-1.1.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kfst-1.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 691ca086e5a41c965c767b8d885fdd06ef3ef97de0deacbc8ee946373804d923
MD5 713fa1a90068a5bb1f764b37039d2cc3
BLAKE2b-256 758ed38e988ebf240b70f81488dfed97ee4cbc57cc75da78c3db18a1e86c1683

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kfst-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2e769be8266f4d5e230656ccff49af23b5375fa469a05d94a3295fc4d1a479c
MD5 0cc6922b941cf7ed68d2ded04ee39c89
BLAKE2b-256 5970e530a5066484db36d4baa775ca3bff266da69e766c077053fcde592107ad

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