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.7+ 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; a successful run will log some errors to STDERR (this is working as expected).

Python version support

Pynini 2.0.0 and onward support Python 3. Pynini 2.1 versions (onward) drop Python 2 support. The current release supports Python 3.6--3.12.

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

Uploaded Source

Built Distributions

pynini-2.1.6-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl (98.8 MB view details)

Uploaded PyPy manylinux: glibc 2.28+ x86-64

pynini-2.1.6-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl (98.8 MB view details)

Uploaded PyPy manylinux: glibc 2.28+ x86-64

pynini-2.1.6-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl (98.8 MB view details)

Uploaded PyPy manylinux: glibc 2.28+ x86-64

pynini-2.1.6-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl (98.8 MB view details)

Uploaded PyPy manylinux: glibc 2.28+ x86-64

pynini-2.1.6-cp312-cp312-manylinux_2_28_x86_64.whl (154.7 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.28+ x86-64

pynini-2.1.6-cp311-cp311-manylinux_2_28_x86_64.whl (154.8 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

pynini-2.1.6-cp310-cp310-manylinux_2_28_x86_64.whl (154.5 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

pynini-2.1.6-cp39-cp39-manylinux_2_28_x86_64.whl (154.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

pynini-2.1.6-cp38-cp38-manylinux_2_28_x86_64.whl (154.7 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

pynini-2.1.6-cp37-cp37m-manylinux_2_28_x86_64.whl (154.4 MB view details)

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

File details

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

File metadata

  • Download URL: pynini-2.1.6.tar.gz
  • Upload date:
  • Size: 789.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pynini-2.1.6.tar.gz
Algorithm Hash digest
SHA256 b09b6dda73608cedf962dbfbcfa5826b0984d1b43a8f995761972e6e032921c6
MD5 7e5cddfed3833767661b3bca470d4cc4
BLAKE2b-256 9b694b59968b0fd351a153d7a3c2feaa6e7514c903c063bbd7f7e1e3f1c079b0

See more details on using hashes here.

File details

Details for the file pynini-2.1.6-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.6-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bb6bef42826b015d778ae6874e3972e8d06417c7f48c7d7635a2bef7d13eb840
MD5 48e467163b1d914c5c400d07fbedaf34
BLAKE2b-256 f325e5c69822c420a9fbde5f76df6e482e370d24bcebd6cacd9e12c829aaabaf

See more details on using hashes here.

File details

Details for the file pynini-2.1.6-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.6-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1a856cb4314602db27b293b9380ba1c77077e33e21860ece24eedcc1a70aa3f0
MD5 08941622d169af27bdd3eaf7693a2627
BLAKE2b-256 dc2972cbb297d90441221bee50e47b5bdfb01ab6c1c50aca6aa2b016bac211ae

See more details on using hashes here.

File details

Details for the file pynini-2.1.6-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.6-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e40421f06f0b95301078fe64899d83f7d102cf437a0ac283e99eac8d7d17626b
MD5 f6ffd27d911fa685fae1c41dc429195d
BLAKE2b-256 7fefea8bd3327d1ded63aea3833933f07fa688bcdaf1a5029097b80af3122f35

See more details on using hashes here.

File details

Details for the file pynini-2.1.6-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.6-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f9ad3b8eac04a02510cfb4628e45eba2d34cce01d742cdacb591acc9c294dfa2
MD5 887ad79c00c3f72710990aa651660cae
BLAKE2b-256 46f2853a7b923a3c6654de2acc2606618fe8455ebf550bc454594b8b5e3bb8c4

See more details on using hashes here.

File details

Details for the file pynini-2.1.6-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f32d1c0b3aa05a76153c7e0e395e553e93acddf4a436cbec5d50d1eb1d354bcd
MD5 47972e69bb5c87b5004d0bfb455bbf2a
BLAKE2b-256 b334403a5e792a8454168c9b9e8b7d8141027e9fb5453013d2f9320e0b083333

See more details on using hashes here.

File details

Details for the file pynini-2.1.6-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a9c2b168bc2b5c6cee82a77515122ad14cbdcd9292cb050eb2824b1b48be1b37
MD5 8ef8c6f631812e60239591ec6079bf37
BLAKE2b-256 6c83801b61aba6e089209387bf47e4bde5201acea990bb8311ddabca9e547e92

See more details on using hashes here.

File details

Details for the file pynini-2.1.6-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d04d3000cda1cd006c791d8c08ecf9472e3710430024b3130eac3fad26afee60
MD5 8b90be5c1da905b64a0abf386ddfd89e
BLAKE2b-256 56814bb768d67943088a0bc12d9f3581e7edc9addf4b29b91f65b4ed733c0a0f

See more details on using hashes here.

File details

Details for the file pynini-2.1.6-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.6-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 294c9ae1c9db54f6d3f235f240332c9f5c84409df5f62c695fe609b337277f4d
MD5 1aa53e42fe670ac670e2c3c5b5326a4e
BLAKE2b-256 168f8cf07be05502187bb5fad3f711399a13b67185cd684f97c7114d1398ac2c

See more details on using hashes here.

File details

Details for the file pynini-2.1.6-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.6-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 58cf8cfb4a7ec951cf6602bb7f1683139a1ae1cd55aa3d0b89aad76017158904
MD5 b903582b612a9ad8a4bcc3e58272579e
BLAKE2b-256 ae8f7fc640d272504912b64d1c5611100fc143ae3e729aa44a76c69b61416f55

See more details on using hashes here.

File details

Details for the file pynini-2.1.6-cp37-cp37m-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynini-2.1.6-cp37-cp37m-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 36813f54676b212cea8342f37b6ed2b05b6a501918e8a216fad93fbd279b2839
MD5 79d3d88a7bc917d80b4080b44fcae6d1
BLAKE2b-256 b08996579401213151c79653265cf5796de9b64ad646557da143b5e8d54a72f0

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