【问题标题】:How to increase Dictionary size in gensim while making Corpus?如何在制作语料库时增加 gensim 中的字典大小?
【发布时间】:2017-05-10 19:44:27
【问题描述】:

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

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。无论如何我不能限制字典的大小?

【问题讨论】:

    标签: python dictionary gensim


    【解决方案1】:

    这里是解释https://radimrehurek.com/gensim/corpora/dictionary.html。参数prune_at设置为2000000,根据你使用的功能可以改成None,避免丢弃的问题。

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

    【讨论】:

      最近更新 更多