Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sfischer13/python-arpa
:snake: Python library for n-gram models in ARPA format
https://github.com/sfischer13/python-arpa
arpa computational-linguistics language-model library lm nlp python python-3
Last synced: 5 days ago
JSON representation
:snake: Python library for n-gram models in ARPA format
- Host: GitHub
- URL: https://github.com/sfischer13/python-arpa
- Owner: sfischer13
- License: mit
- Created: 2015-06-20T17:49:22.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T07:42:35.000Z (about 2 years ago)
- Last Synced: 2024-04-25T02:26:11.838Z (9 months ago)
- Topics: arpa, computational-linguistics, language-model, library, lm, nlp, python, python-3
- Language: Python
- Homepage:
- Size: 201 KB
- Stars: 38
- Watchers: 3
- Forks: 13
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
Python ARPA Package
===================Python library for reading ARPA n-gram models.
- [Documentation](https://arpa.readthedocs.io/en/latest/) is available.
- [Changes](https://github.com/sfischer13/python-arpa/blob/master/HISTORY.md) between releases are documented.
- [Bugs](https://github.com/sfischer13/python-arpa/issues) can be reported on the issue tracker.
- [Questions](mailto:[email protected]) can be asked via e-mail.
- [Source code](https://github.com/sfischer13/python-arpa) is tracked on GitHub.Setup
-----### Python 3.4+
[![PyPI Python Versions](https://img.shields.io/pypi/pyversions/arpa.svg)](https://pypi.python.org/pypi/arpa) [![PyPI Version](https://img.shields.io/pypi/v/arpa.svg)](https://pypi.python.org/pypi/arpa)
In order to install the Python 3 version:
$ pip install --user -U arpa
### Python 2.7
[![PyPI Python Versions](https://img.shields.io/pypi/pyversions/arpa-backport.svg)](https://pypi.python.org/pypi/arpa-backport) [![PyPI Version](https://img.shields.io/pypi/v/arpa-backport.svg)](https://pypi.python.org/pypi/arpa-backport)
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.7models = 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](https://img.shields.io/travis/sfischer13/python-arpa.svg)](https://travis-ci.org/sfischer13/python-arpa) [![Documentation Status](https://readthedocs.org/projects/arpa/badge/?version=latest)](https://arpa.readthedocs.io/en/latest/?badge=latest) [![Coverage Status](https://coveralls.io/repos/sfischer13/python-arpa/badge.svg?branch=master&service=github)](https://coveralls.io/github/sfischer13/python-arpa?branch=master)
*Contributions are welcome!*
Write a bug report or send a pull request.
Other [contributors](https://github.com/sfischer13/python-arpa/graphs/contributors) have done so before.License
-------Copyright (c) 2015-2018 Stefan Fischer
The source code is available under the **MIT License**.
See [LICENSE](https://github.com/sfischer13/python-arpa/blob/master/LICENSE) for further details.