google-ngram
v1.0.16
Published
A simple package to interact with the Google Books Ngram API.
Downloads
10
Readme
google-ngram
A simple package to interact with the Google Books Ngram API.
Example Usage:
const ngram=require('google-ngram')
//simple usage
ngram.getNGram('the').then(r => console.log(r))
//with options
ngram.getNGram('the', {year_start: 1920, corpus: 10}).then(r => console.log(r))
//multiple words
ngram.getNGram('the, and').then(r => console.log(r))
//with wildcard
ngram.getNGram('the *').then(r => console.log(r))
getNGram(Content, Options) => Promise: Array
Content
| Type | Notes | | --- | --- | | String | Required |
Options
| Type | Parameters | Default Values | Notes | | --- | --- | --- | --- | | Object | {corpus: int, smoothing: int, year_start: int, year_end: int, case_insensitive: boolean} (all are optional)| {corpus: 26 (English Corpus), smoothing: 3, year_start: 1800, year_end: 2019, case_insensitive: false} | Optional |
Parameter Information:
| Corpus | Number | | ---| ---| | English 2019 (Default) |26| | American English 2019 | 28 | | British English | 29 | | English Fiction | 27 | | Chinese(Simplified) | 34 | | French | 30 |
Returned Data:
[
{
"ngram": "<word>",
"parent": "", //used for wildcard
"type": "NGRAM",
"timeseries": [
0.057974955067038536,
0.057649505138397214,
0.057653142139315605,
0.05750594554202897,
...
]
}
... //for multiple words or wildcard
]