Skip to content

sfischer13/python-arpa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

861a19b · Apr 10, 2021
Dec 12, 2018
Dec 12, 2018
Dec 10, 2018
Sep 13, 2015
Jun 5, 2017
Dec 4, 2018
Apr 28, 2018
Dec 2, 2018
Dec 3, 2018
Dec 2, 2018
Dec 7, 2018
Dec 12, 2018
Apr 27, 2018
Dec 8, 2018
Apr 10, 2021
Apr 10, 2021
Dec 7, 2018
Apr 10, 2021
Apr 10, 2021
Apr 29, 2018
Dec 12, 2018

Repository files navigation

Python ARPA Package

Python library for reading ARPA n-gram models.

Setup

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

Usage

The package may be imported directly:

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

models = arpa.loadf("foo.arpa")
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)

Development

Travis Documentation Status Coverage Status

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

License

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