OpenGrm installation instructions

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 easy way

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.

The hard way

To begin installation, you will need:

  1. Python 3.6 or better:
  2. A compiler that supports C++11, C99, and POSIX:
    1. On Windows 10, install the Windows Subsystem for Linux.
    2. On Mac OS X, in a terminal window, type xcode-select --install and follow the prompts.
    3. On Linux, install the appropriate package from your distribution; for instance for Ubuntu, type sudo apt install build-essential and follow the prompts.

OpenFst

OpenFst is a C++ library which acts as a backend for both tools.

  1. Visit http://www.openfst.org. Click on "Download", then click on the link for the current version (openfst-1.7.5.tar.gz) and save the file to your hard drive.
  2. 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
    
  3. This will create a directory called openfst-1.7.5; enter it:

    $ cd openfst-1.7.5
    
  4. Issue the following commands to compile and install it:

    $ ./configure --enable-grm && make -j4 && sudo make -j4 install

NGram

  1. Visit http://ngram.opengrm.org. Click on "Download", then click on the link for the current version (opengrm-ngram-1.3.8.tar.gz) and save the file to your hard drive.
  2. In your terminal window, navigate to the directory containing the file you just downloaded and decompress it:

    $ tar xvzf ngram-1.3.8.tar.gz
    
  3. This will create a directory called ngram-1.3.8; enter it:

    $ cd ngram-1.3.8
    
  4. Issue the following commands to compile and install it:

    $ ./configure && make -j4 && sudo make -j4 install
    

Pynini

Pynini is a Python library for finite-state grammar compilation.

  1. Visit http://pynini.opengrm.org. Click on "Download", then click on the link for the current version (pynini-2.0.9.post2.tar.gz) and save the file to your hard drive.
  2. 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
    
  3. This will create a directory called pynini-2.0.9.post2; enter it:

    $ cd pynini-2.0.9.post2
    
  4. 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
    

Testing

Notes