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 thegrm
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
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
Hashes for pynini-2.1.5.post2-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33fe11373af154cae287996b15074d179e8ef79973577eb4ba8462c4067baa3f |
|
MD5 | 1c2899c75dd56aa07304d738940bf5b7 |
|
BLAKE2b-256 | 865b17910e58957d9c2bc2fec0f1ae5f925627362ff86e1ff1a054b4aa3f3832 |
Hashes for pynini-2.1.5.post2-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54e303d9c605677ebd8aa7977912a019ad18b874482dd78a18d858f549c9f70d |
|
MD5 | 2f76d3e4c55589d207ee32d03ccda3cb |
|
BLAKE2b-256 | d1aece8b50a53e2a9e46fd10b445548fa46d23c424afc8f8d13c1f956a5dc9c9 |
Hashes for pynini-2.1.5.post2-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 182bc50e747904980658d43dfc4fb209e2ac60ee6c10b5e9729440f4b83a0064 |
|
MD5 | 972760f0bc6e376c3c3b0467b9df6120 |
|
BLAKE2b-256 | 28a46c74039dd7cd61d8351f6f740920a23d63960ced6bbae6095a1fe526279c |
Hashes for pynini-2.1.5.post2-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d0ff589da6387f2050a7780b5a14ac27cc512adb4086512444ed52ec6a9b4c0 |
|
MD5 | c7ece2ebbc6ce2aa04d2b9cb51e51670 |
|
BLAKE2b-256 | e177c45057f45f23952bd09c77a15bd6b9852925b30184fd10ae287b74373ed6 |
Hashes for pynini-2.1.5.post2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b0ff4ac50db0912ad34bd23c8c749fc8f1b68febe6c4f79ce71a916640dd37b |
|
MD5 | b3c45c4f2524766fa79e8c108dfac138 |
|
BLAKE2b-256 | 8200cee0aa9525b099277d782861a06dd6dceba1a862949e2dece28eef5b6148 |
Hashes for pynini-2.1.5.post2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac439e85818f19effbcdd9948b5d99a156d4c40a73b283abb2f250b1b94079d2 |
|
MD5 | 77d82298bc6631bf558f565cc7639533 |
|
BLAKE2b-256 | 887dad68a3cbce7a5157563af87aee17bbbe58461331692333cc03fdc327669b |
Hashes for pynini-2.1.5.post2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82489615fb1865beec5e5bf3d1577ade4568dd4bdb132db914c9ec3369c46bda |
|
MD5 | d748fc5dc90a7bef1425f8fb285405ee |
|
BLAKE2b-256 | 0b6add07d6a4457a604570796d6d4e85f825f06f98d9ce8a2a94a06bcff75fdd |
Hashes for pynini-2.1.5.post2-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7422b546c3de6e68212a6311b659f79642f5aee68d52803523e938350839ded |
|
MD5 | 4d42440769412287b9aa2a8273700356 |
|
BLAKE2b-256 | ab551d3d1e5891163f61cb8a2e062713058592f6411d63c47b51c4cf92788d85 |
Hashes for pynini-2.1.5.post2-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59031186783b253d05e9c1721cd15da3dc95049d0a2a3d8d9994542ab61201c0 |
|
MD5 | ad3568dc0eb623347b13222ed9c9670e |
|
BLAKE2b-256 | a6d493761f6d8845c5b4e959ff56b157dd4ea109ec03b1acf9babcfa7cbaad83 |
Hashes for pynini-2.1.5.post2-cp37-cp37m-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9db97ce5ee93781e75636a82cab296e116fa60f1a3495286696165363a65acb4 |
|
MD5 | 7d416f94fd4506bd1a215d655e8e93ec |
|
BLAKE2b-256 | 0458cb4c908c2dcf3c267aea03cfe967c7cd59d52f64aad9e69012db9f7ba5fb |
Hashes for pynini-2.1.5.post2-cp36-cp36m-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8b1ebe2ab239b06d70eaf58d45ebeb5cfdd3e2ec95685154e89be458e282d9e |
|
MD5 | 18829160e2f7f6eddc6814cf9c26a60b |
|
BLAKE2b-256 | f3c7e877f3b1e61b8fa9cdff576e9a84d150a5c0292ce1509e59aba4a2026b1b |