Google ngram downloader
The Google Books Ngram Viewer dataset is a freely available resource under a Creative Commons Attribution 3.0 Unported License which provides ngram counts over books scanned by Google.
The data is so big, that storing it is almost impossible. However, sometimes you need an aggregate data over the dataset. For example to build a co-occurrence matrix.
This package provides an iterator over the dataset stored at Google. It decompresses the data on the fly and provides you the access to the underlying data.
Features
Download ngrams of various length and languages.
Access to part of ngrams, e.g. ones that start with an ‘a’.
Installation
pip install google-ngram-downloader
The command line tool
It also provides a simple command line tool to download the ngrams called google-ngram-downloader. Refer to the help to see available actions:
google-ngram-downloader help usage: google-ngram-downloader <command> [options] commands: cooccurrence Write the cooccurrence frequencies of a word and its contexts. download Download The Google Books Ngram Viewer dataset version 20120701. help Show help for a given help topic or a help overview. readline Print the raw content.
Example use of the API
>>> from google_ngram_downloader import readline_google_store >>> >>> fname, url, records = next(readline_google_store(ngram_len=5)) >>> fname 'googlebooks-eng-all-5gram-20120701-0.gz' >>> url 'http://storage.googleapis.com/books/ngrams/books/googlebooks-eng-all-5gram-20120701-0.gz' >>> next(records) Record(ngram=u'0 " A most useful', year=1860, match_count=1, volume_count=1)
Changes
Version 4.0.1
Citation information.
Tests are correctly packaged for a release.
Version 4.0.0
Added ‘indices’ keyword. Thanks to neocortex.
Added ‘language’ flat. Thanks to Ray Powell (rpowellgit).
Version 3.1.1
Non-unique contexts are taken into account inside of an ngram.
Version 3.1
The cooccurrence command does not perform any ngram modification.
Version 3.0
download, readile and cooccurrence subcommands.
readline_google_store transforms lines to Record in several processes.
Metadata
Release files for google-ngram-downloader 4.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| google-ngram-downloader-4.0.1.tar.gz | 12.2 kB | Without provenance | Details |
Release files / google-ngram-downloader-4.0.1.tar.gz
| Download URL | google-ngram-downloader-4.0.1.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c53520de654c1340a778f6f70f9e255a88894661c9ed20bcae6ee564f4f3c269
|
|
BLAKE2b-256 checksum How to use checksums |
6e1806f89c493fbdf753163322e19a1680f67139526a7da7fd0cd506d5591ac5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for google-ngram-downloader 4.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.