繁体   English   中英

制作语料库时如何增加gensim中的Dictionary大小?

[英]How to increase Dictionary size in gensim while making Corpus?

我正在使用命令制作语料库

background_corpus = TextCorpus('wiki.en.text')

这是一个超过10 GB的文件,因此在制作该语料库并将其添加到字典时会给出

adding document #820000 to Dictionary(2000000 unique tokens: [u'tripolitan', u'ftdna', u'soestdijk', u'billycorgan', u'olmsville']...)

discarding 31072 tokens: [(u'vnsas', 1), (u'ezequeel', 1), (u'trapeztafel', 1), (u'pubsub', 1), (u'gyvenimas', 1), (u'gilibrand', 1), (u'catfaced', 1), (u'beuningan', 1), (u'moodadi', 1), (u'nocaster', 1)]...

keeping 2000000 tokens which were in no less than 0 and no more than 830000 (=100.0%) documents

因此,它丢弃了新令牌,因为它的最大大小为2000000。反正我不能限制字典的大小吗?

这是解释https://radimrehurek.com/gensim/corpora/dictionary.html 参数prune_at设置为2000000 ,具体取决于所使用的函数,可以将其更改为None以避免丢弃的问题。

编辑:在gensim / corpora / dictionary.py(init函数当前版本中的第45行)中,您可以设置prune_at = None或设置自己的限制(例如5000000,例如prune_at = 5000000 )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM