Finite-state grammar compilation
Project description
OpenGrm Pynini
This is 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.)
Dependencies
- A standards-compliant C++17 compiler (GCC >= 7 or Clang >= 700)
- OpenFst 1.8.4 built with the
grmextensions (i.e., with./configure --enable-grm) and headers - Python 3.9+ and headers
Installation instructions
There are various ways to install Pynini depending on your platform.
Windows
The pre-compiled library can be installed from
conda-forge by running
conda install -c conda-forge pynini.
Alternatively, it can also 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.
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.9--3.13.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pynini-2.1.7.tar.gz.
File metadata
- Download URL: pynini-2.1.7.tar.gz
- Upload date:
- Size: 789.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc06cc02adcbd4b14eb94ae9f2a0949d110612d2d4ee3a7ac5dc97b45fff8e33
|
|
| MD5 |
2788b4bdfe042321c71858039ed571e1
|
|
| BLAKE2b-256 |
c6b609a0efe843df37d9c80a9a1c190c7bb28d8920cee401e2a61c46f1328ec1
|
File details
Details for the file pynini-2.1.7-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pynini-2.1.7-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 100.6 MB
- Tags: PyPy, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ac00901ad876f684dc7d3f57057545e9a064149f3e87ff2dd08b38ab1dc0f90
|
|
| MD5 |
2bce6c60b8cbaaaa6f24fa2b72e07384
|
|
| BLAKE2b-256 |
5e193a97b5eb33ea23e8e918957ddffd2c5d08582a7aef0abdd9fcdaba3143b1
|
File details
Details for the file pynini-2.1.7-pp310-pypy310_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pynini-2.1.7-pp310-pypy310_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 100.6 MB
- Tags: PyPy, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64403cb3fe1ca265a74688ba35fb294ed38eb8c7645c109e24225befcf9b0dee
|
|
| MD5 |
398e8988165b178344afea2f98a15bb6
|
|
| BLAKE2b-256 |
a1e53b37743563f9b63101de6cf7c66bb895767f38dc47970ec9545a60740693
|
File details
Details for the file pynini-2.1.7-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pynini-2.1.7-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 165.4 MB
- Tags: CPython 3.14t, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bb5de3d52056a228dd48a6d027fc279f0c94a11f28bc43b79c43a1624ec032d
|
|
| MD5 |
89dafdbe49ac58f38d0ee4b6f2c982ed
|
|
| BLAKE2b-256 |
6141fd9c867fbe1a9141ea57a59e6a8b087ba88f19e97bd46b39dcf77ed00ecb
|
File details
Details for the file pynini-2.1.7-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pynini-2.1.7-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 165.5 MB
- Tags: CPython 3.14, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaf2171cf5d744961d1080a680f1725807b4d179588a6ad3135596c2e0e06bc0
|
|
| MD5 |
28fbdff428a54a36be40f7cb8927f26e
|
|
| BLAKE2b-256 |
272374fb65f0cdd345b8b186f80a3bdd318e93906b572cd82721a16bee9b1eaa
|
File details
Details for the file pynini-2.1.7-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pynini-2.1.7-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 165.4 MB
- Tags: CPython 3.13t, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7e59fc8ac5eed9234f9d394e882bd7048808590e15abcce5ce03662b8e5ea79
|
|
| MD5 |
9d8b4f4abed127b7bbb6f5a94c09019d
|
|
| BLAKE2b-256 |
88c2d47eae721b2ac558d72c61250ee64918cff453e40d5c02db53ec21983ef9
|
File details
Details for the file pynini-2.1.7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pynini-2.1.7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 165.5 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
764ae36dd9f3480e88c4d4046d108a74c4923510d0aa93062debfe1f742b356f
|
|
| MD5 |
953e32df9f89b386837bb2ef1019c497
|
|
| BLAKE2b-256 |
a99bdcbf23733cd57a86dc4aa425aba2a4efff301acf152e50065c232449ade6
|
File details
Details for the file pynini-2.1.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pynini-2.1.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 165.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
574985fb1cae220ac96caa30476d764fe6d8991cc4f378d83e276591118eb10a
|
|
| MD5 |
c41154e2cb1eb6fde5a604c565a1ad58
|
|
| BLAKE2b-256 |
ef168624f73412f4571517dc97e027c6b73db849c7c649aad70aa2dd168834a1
|
File details
Details for the file pynini-2.1.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pynini-2.1.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 165.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d078331bf24d2f46d3ff8940f558b88ce059ad72a37c0019b0411b03a136d986
|
|
| MD5 |
a2dec8e61a3620bb2da24c4cdcbfc635
|
|
| BLAKE2b-256 |
624bd3a90b0355e28bcd28e4377b9d2b536884de9ae9aa74a78886971467a8dd
|
File details
Details for the file pynini-2.1.7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pynini-2.1.7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 165.4 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
644f75b67a591f668b26318b6d98514a85be5264b4117f50f358901e4513c901
|
|
| MD5 |
3b1d6e3203cec40b8c05e54c69a02c20
|
|
| BLAKE2b-256 |
b020fd233d658ce68b335ba6387dbc9497288c00b13d1bd54f47156bf785948d
|
File details
Details for the file pynini-2.1.7-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pynini-2.1.7-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 165.4 MB
- Tags: CPython 3.9, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19180e366e2e1271f424385763c25032d36b08208b71e8b42eec14465344cdb9
|
|
| MD5 |
91417689bb04c17651fc201845dd6c60
|
|
| BLAKE2b-256 |
f872ba5d5ac34f66e414def0aede1996874bb6c7e85518d149854038f71aa7b6
|