簡體   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