谷歌ngram数据的流媒体访问。
google-ngram-downloader的Python项目详细描述
The Google Books Ngram Viewer dataset是 提供ngram的Creative Commons Attribution 3.0 Unported License 超过了谷歌扫描的书籍数量。
数据太大,几乎不可能存储。然而,有时 您需要数据集上的聚合数据。例如构建 共现矩阵。
这个包提供了对存储在google上的数据集的迭代器。它 动态解压缩数据并提供对底层的访问 数据。
功能
- 下载不同长度和语言的ngram。
- 访问部分ngram,例如以“a”开头的ngram。
安装
pip install google-ngram-downloader
命令行工具
它还提供了一个简单的命令行工具来下载名为 谷歌ngram下载程序。请参阅帮助以查看可用操作:
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.
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)
更改
版本4.0.1
- 引文信息。
- 测试已正确打包以供发布。
版本4.0.0
- 添加了“索引”关键字。多亏了新皮质。
- 添加了“语言”平面。多亏了雷·鲍威尔(Rpowellgit)。
版本3.1.1
- ngram内部考虑了非唯一上下文。
版本3.1
- cooccurrence命令不执行任何ngram修改。
版本3.0
- 下载,readile和共现子命令。
- readline_google_store在几个过程中将行转换为记录。