python - 使用 google_ngram_downloader 阅读谷歌 ngram

标签 python nlp

我正在使用 google_ngram_downloader 读取谷歌数据集。

代码:

from google_ngram_downloader import readline_google_store
fname, url, records = next(readline_google_store(ngram_len=1))
for x in range(0,5):
    print next(records)

这里我正在一个一个地阅读数据集从0,1,... a,b,c.. z开始next(readline_google_store(ngram_len=1)) 一个一个给出 ngram。我想直接读取数据集,这些数据集将 'a','b' 不是一个一个地读取。

必需:只读数据集,以字母'a' 开头,具有1-gram 数据集。

最佳答案

一种方法是显式添加索引。使用此行仅获取以 a 开头的长度为 1 的 ngram。

fname, url, records = next(readline_google_store(ngram_len=1,indices='a'))

关于python - 使用 google_ngram_downloader 阅读谷歌 ngram,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26624642/

相关文章:

python - 练习 Linux Shell 脚本编写

python - 在 Python 中更新字典

VS 2015 中的 Python IntelliSense/代码完成

python - 如何在nlp中进行特征提取

python - 海象运算符 : if contition with strange results

python - 无法使用 python 脚本更改 docker 容器内的工作目录

python - NLP 问题处理带连词的句子

neural-network - Torchtext 属性错误 : 'Example' object has no attribute 'text_content'

r - 文档术语矩阵中的最大术语长度

python - 删除 NER 处的 B 和 I 标记