Skip to main content

Library for reading ARPA n-gram models with Python 2.7.

Project description

Python ARPA Package

Python library for reading ARPA n-gram models.


Python 3.4+

PyPI Python Versions PyPI Version

In order to install the Python 3 version:

$ pip install --user -U arpa

Python 2.7

PyPI Python Versions PyPI Version

In order to install the Python 2.7 version:

$ pip install --user -U arpa-backport


The package may be imported directly:

import arpa  # Python 3.4+
# OR
import arpa_backport as arpa  # Python 2.7

models = arpa.loadf("")
lm = models[0]  # ARPA files may contain several models.

# probability p(end|in, the)
lm.p("in the end")
lm.log_p("in the end")

# sentence score w/ sentence markers
lm.s("This is the end .")
lm.log_s("This is the end .")

# sentence score w/o sentence markers
lm.s("This is the end .", sos=False, eos=False)
lm.log_s("This is the end .", sos=False, eos=False)


Travis Documentation Status Coverage Status

Contributions are welcome!
Write a bug report or send a pull request.
Other contributors have done so before.


Copyright (c) 2015-2018 Stefan Fischer
The source code is available under the MIT License.
See LICENSE for further details.


All notable changes to this project will be documented in this file.
This project adheres to Semantic Versioning.
You should Keep a CHANGELOG, too!

Next Release







0.1.0b4 - 2018-12-12

0.1.0b3 - 2018-12-06

First release on PyPI.

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

arpa-backport-0.1.0b4.tar.gz (29.7 kB view hashes)

Uploaded source

Built Distribution

arpa_backport-0.1.0b4-py2-none-any.whl (10.4 kB view hashes)

Uploaded py2

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page