Skip to main content

Finite-state grammar compilation

Project description

OpenGrm Pynini

This is a a Python extension module for compiling, optimizing and applying grammar rules. Rules can be compiled into weighted finite state transducers, pushdown transducers, or multi-pushdown transducers. It uses OpenFst finite-state transducers (FSTs) and FST archives (FArs) as inputs and outputs.

This library is primarily developed by Kyle Gorman.

If you use Pynini in your research, we would appreciate if you cite the following paper:

K. Gorman. 2016. Pynini: A Python library for weighted finite-state grammar compilation. In Proc. ACL Workshop on Statistical NLP and Weighted Automata, 75-80.

(Note that some of the code samples in the paper are now out of date and not expected to work.)

Dependencies

  • A standards-compliant C++17 compiler (GCC >= 7 or Clang >= 700)
  • The compatible recent version of OpenFst (see NEWS for this) built with the grm extensions (i.e., built with ./configure --enable-grm) and headers
  • Python 3.6+ and headers

Installation instructions

There are various ways to install Pynini depending on your platform.

Windows

While Pynini is neither designed for nor tested on Windows, it can be installed using the Windows Subsystem for Linux (WSL). Simply enter the WSL environment and follow the Linux instructions below.

MacOS

The pre-compiled library can be installed from conda-forge by running conda install -c conda-forge pynini.

Alternatively, one can build from source from PyPI by running pip install pynini.

Finally, one can use Bazel to build from source by running bazel build //:all anywhere in the source tree.

Linux

The pre-compiled library can be installed from conda-forge by running conda install -c conda-forge pynini.

Alternatively, one can install a pre-compiled manylinux wheel from PyPI by running pip install pynini. This will install the pre-compiled manylinux wheel (if available for the release and compatible with your platform), and build and install from source if not. Unlike the conda-forge option above, which also installs OpenFst and Graphviz, this does not install the OpenFst or Graphviz command-line tools. See the enclosed Dockerfile for instructions for building and deploying manylinux wheels.

Finally, one can use Bazel to build from source by running bazel build //:all anywhere in the source tree.

Testing

To confirm successful installation, run pip install -r requirements, then python tests/pynini_test.py. If all tests pass, the final line will read OK.

Python version support

Pynini 2.0.0 and onward support Python 3. Pynini 2.1 versions (onward) drop Python 2 support.

License

Pynini is released under the Apache license. See LICENSE for more information.

Interested in contributing?

See CONTRIBUTING for more information.

Mandatory disclaimer

This is not an official Google product.

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

pynini-2.1.5.tar.gz (627.6 kB view details)

Uploaded Source

Built Distributions

pynini-2.1.5-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (163.3 MB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pynini-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (154.7 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pynini-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (161.3 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pynini-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (161.3 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pynini-2.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (161.5 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pynini-2.1.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (161.1 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pynini-2.1.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (161.1 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

File details

Details for the file pynini-2.1.5.tar.gz.

File metadata

  • Download URL: pynini-2.1.5.tar.gz
  • Upload date:
  • Size: 627.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.61.2 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.5

File hashes

Hashes for pynini-2.1.5.tar.gz
Algorithm Hash digest
SHA256 c32a55228aea4e3a3daa0d22ba0ea89ea90c17151c3a0fd5703b699d4e7d4e9b
MD5 cc24f22617c142f0399462a52b8c87dd
BLAKE2b-256 86636a720dbdf4e7358baa2ab206a51693f9c6e83d174179a95539f501bd4a34

See more details on using hashes here.

File details

Details for the file pynini-2.1.5-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: pynini-2.1.5-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 163.3 MB
  • Tags: PyPy, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for pynini-2.1.5-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a0b8a9be2297cac7f3aced98ffd8c85be6bcc6229079374994d2699588a145d
MD5 616feaa979e7b6b3984e8bb18e73f08b
BLAKE2b-256 c8cffb25b864b923f40bbe6724415105283d98d4424a8e91bdc99ef3be457754

See more details on using hashes here.

File details

Details for the file pynini-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c9473cf25231a92a4e2e2226d79036d115c09e2e362dbcf5bc4cbd872b9bf40
MD5 fd0f69d11c7fadc8bd06d9e017878a13
BLAKE2b-256 ab832708b2ddef8d6d780e6ac7f9801635e99912b5d3aeeeddf2cbb322688595

See more details on using hashes here.

File details

Details for the file pynini-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 29ea2c3b8218a87934d8707eceac573d88dc5e8797380711dcb314af203a3eb0
MD5 7427c5ac8c10e4fdcda5a6c49e0ee898
BLAKE2b-256 e707f3b8869878093fe7d119cbdcc97de0b64e4b8e2a7933c817fcef1fe455bb

See more details on using hashes here.

File details

Details for the file pynini-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: pynini-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 161.3 MB
  • Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for pynini-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aba4221843ad23f9e56169f6f7740970e903112944dfec6153aa23979701c304
MD5 8fbde3aea6171252a8b68dbf6f675c4d
BLAKE2b-256 87fe4982fafd75bd04daf1b74e5a4b4190a2a5fb49f2bd1dc3e56c8f29ea1e50

See more details on using hashes here.

File details

Details for the file pynini-2.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: pynini-2.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 161.5 MB
  • Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for pynini-2.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4eedc1ea32d4e44c5bafd726f6c2c700ebbeaf006eb0b40240e78c967613267e
MD5 a0eb159e7672d76bd63ca8c29498df0f
BLAKE2b-256 90e135813e174a5cbba9c45cb28b3431d5b47edfbd953086201d17309be82bda

See more details on using hashes here.

File details

Details for the file pynini-2.1.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: pynini-2.1.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 161.1 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for pynini-2.1.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dc61e85445310ce604c53ed52d051af9f965ee186c43b4726e1877990d107c7b
MD5 076789e97d9fb775d9424ddd260c7fa5
BLAKE2b-256 05378b9472b16d81846c87c558429aab79f8aa8cf5cec9fc96c96ab56f5c41ea

See more details on using hashes here.

File details

Details for the file pynini-2.1.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: pynini-2.1.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 161.1 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for pynini-2.1.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 59f2616e7853cc55d081960a3af4111ed5a6b8a9423ed55dbc6540ddbdd30bce
MD5 9025467bb8efa7f8bed4625dc2aa1ed2
BLAKE2b-256 3a12e39fb99bdaad2287022341bf90bd003346ca3ca7f80de1bc34abfcb5865a

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