This document covers installation of two libraries: NGram, a C++ library for building finite-state language models, and Pynini, a Python library for finite-state grammar development. Both are part of the OpenGrm project and depend on OpenFst, another C++ library.
The easiest way to install these dependencies is via Anaconda. If you already have a working conda installation, you can just issue the following command:
$ conda install ngram pynini -c conda-forge
to install all the libraries you'll need.
To begin installation, you will need:
xcode-select --install
and follow the prompts.sudo apt install build-essential
and follow the prompts.OpenFst is a C++ library which acts as a backend for both tools.
openfst-1.7.5.tar.gz
) and save the file to your hard drive.In your terminal window, navigate to the directory containing the file you just downloaded and decompress it:
$ tar xvzf openfst-1.7.5.tar.gz
This will create a directory called openfst-1.7.5
; enter it:
$ cd openfst-1.7.5
Issue the following commands to compile and install it:
$ ./configure --enable-grm && make -j4 && sudo make -j4 install
opengrm-ngram-1.3.8.tar.gz
) and save the file to your hard drive.$ tar xvzf ngram-1.3.8.tar.gz
This will create a directory called ngram-1.3.8
; enter it:
$ cd ngram-1.3.8
Issue the following commands to compile and install it:
$ ./configure && make -j4 && sudo make -j4 install
Pynini is a Python library for finite-state grammar compilation.
pynini-2.0.9.post2.tar.gz
) and save the file to your hard drive.In your terminal window, navigate to the directory containing the file you just downloaded and decompress it:
$ tar xvzf pynini-2.0.9.post2.tar.gz
This will create a directory called pynini-2.0.9.post2
; enter it:
$ cd pynini-2.0.9.post2
Issue the following commands to compile and install it:
$ python setup.py install
If you are on Mac OS X and encounter an error here, try the following instead:
$ CFLAGS=-stdlib=libc++ python setup.py install
import pynini
.ngraminfo --helpshort
.