Skip to main content

The streaming access to the Google ngram data.

Project description

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.

Example use

>>> from google_ngram_downloader import readline_google_store
>>> fname, url, records = next(readline_google_store(ngram_len=5))
>>> fname
>>> url
>>> next(records)
Record(ngram='0 " A most useful', year=1860, match_count=1, volume_count=1)


pip intall google-ngram-downloader

The command line tool

It also provides a simple command line tool to download the ngrams:

$ google-ngram-downloader -h
google-ngram-downloader [OPTIONS] [NGRAM_LEN]

Download The Google Books Ngram Viewer dataset version 20120701.


 -n --ngram-len  The length of ngrams to be downloaded. (default: 1)
 -o --output     The destination folder for downloaded files. (default:
 -v --verbose    Be verbose.
 -h --help       display help

Project details

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