Skip to main content

Google ngram downloader

https://travis-ci.org/dimazest/google-ngram-downloader.png?branch=master https://coveralls.io/repos/dimazest/google-ngram-downloader/badge.png?branch=master

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
'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='0 " A most useful', year=1860, match_count=1, volume_count=1)

Installation

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.

options:

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

Metadata

Release files for google-ngram-downloader 2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for google-ngram-downloader 2
File Size Uploaded
google-ngram-downloader-2.tar.gz 7.2 kB Details

Release files / google-ngram-downloader-2.tar.gz

Download URL google-ngram-downloader-2.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fba846a81d5610173dba5c356325cffd2ced22464af4241a830f35f1d20dbaf4
BLAKE2b-256 checksum
How to use checksums
70392308412d8e892eebd0d55f0d41fe8ee3eac5813d323a19a35ac0cf732ac2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

4.0.1

1 release file

4.0.0

1 release file

3.1.1

1 release file

3.1

1 release file

3.0.1

1 release file

3.0

1 release file

This release

2 This release

1 release file

1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page