Google PyGram
An API interface for Google Book NGrams.
Installation
pip install google-pygram
Usage
from google_pygram import GooglePyGram as gpg
pygram = gpg(
corpus='English',
corpus_year=2019,
start_year=1800,
end_year=2000,
smoothing=3,
case_sensitive=False,
phrases=['hello', 'world']
)
print(pygram.to_df())
# year hello world
# 1800 1800.0 9.921164e-08 0.000379
# 1801 1801.0 6.075895e-08 0.000423
# 1802 1802.0 7.149158e-08 0.000353
# 1803 1803.0 2.593483e-08 0.000338
# 1804 1804.0 8.450996e-08 0.000398
# ... ... ... ...
# 1996 1996.0 1.331358e-06 0.000306
# 1997 1997.0 1.430890e-06 0.000308
# 1998 1998.0 1.523893e-06 0.000317
# 1999 1999.0 1.650712e-06 0.000326
# 2000 2000.0 2.076080e-06 0.000337
Parameters
-
corpus: The corpus to use. Can be one of the following:EnglishChinese (simplified)FrenchGermanHebrewItalianRussianSpanish
-
corpus_year: The year of the corpus to use. Can be one of the following:201920122009
-
start_year: The start year of the ngram. Must be between 1800 and 2000. -
end_year: The end year of the ngram. Must be between 1800 and 2000. -
smoothing: The smoothing parameter. Must be between 0 and 5. -
case_sensitive: Whether or not the ngram is case sensitive. Must be a boolean. -
phrases: A list of phrases to search for. Must be a list of strings.
Methods
add_phrase(phrase): Adds a phrase to the ngram query.to_df(): Returns a pandas DataFrame of the ngram.to_csv(filename): Saves the ngram to a csv file.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
Metadata
Release files for google-pygram 0.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 | |
|---|---|---|---|
| google-pygram-0.0.1.tar.gz | 3.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| google_pygram-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / google-pygram-0.0.1.tar.gz
| Download URL | google-pygram-0.0.1.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e33369997f168c5b51f64cd66c0e0b8a8a118b55bf6655a25b406ef2c18c687e
|
|
BLAKE2b-256 checksum How to use checksums |
dbab42589483abeac78af67117a3a13a8d64a8315bd8adab112147a23741a26f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Release files / google_pygram-0.0.1-py3-none-any.whl
| Download URL | google_pygram-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f1a65a0392b70c526c789c911ed5b5ea07605df00801f87f99d526b63d82526
|
|
BLAKE2b-256 checksum How to use checksums |
4b29ee0ff2f86fe8f2138f1ae424b3a19c67f3c6c3548b826adfbfa46c3998a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|