【发布时间】:2023-09-24 06:08:01
【问题描述】:
当我在大约 1600 万个文档的完整语料库上运行 Gensim LDAMallet 模型时,我收到 CalledProcessError“非零退出状态 1”错误。 有趣的是,如果我在大约 160,000 个文档的测试语料库上运行完全相同的代码,则代码运行得非常好。由于它在我的小型语料库上运行良好,我倾向于认为代码很好,但我不确定还有什么会/可能导致此错误...
我已尝试按照here 的建议编辑 mallet.bat 文件,但无济于事。 我还仔细检查了路径,但这应该不是问题,因为它适用于较小的语料库。
id2word = corpora.Dictionary(lists_of_words)
corpus =[id2word.doc2bow(doc) for doc in lists_of_words]
num_topics = 30
os.environ.update({'MALLET_HOME':r'C:/mallet-2.0.8/'})
mallet_path = r'C:/mallet-2.0.8/bin/mallet'
ldamallet = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, num_topics=num_topics, id2word=id2word)
这是完整的回溯和错误:
File "<ipython-input-57-f0e794e174a6>", line 8, in <module>
ldamallet = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, num_topics=num_topics, id2word=id2word)
File "C:\ProgramData\Anaconda3\lib\site-packages\gensim\models\wrappers\ldamallet.py", line 132, in __init__
self.train(corpus)
File "C:\ProgramData\Anaconda3\lib\site-packages\gensim\models\wrappers\ldamallet.py", line 273, in train
self.convert_input(corpus, infer=False)
File "C:\ProgramData\Anaconda3\lib\site-packages\gensim\models\wrappers\ldamallet.py", line 262, in convert_input
check_output(args=cmd, shell=True)
File "C:\ProgramData\Anaconda3\lib\site-packages\gensim\utils.py", line 1918, in check_output
raise error
CalledProcessError: Command 'C:/mallet-2.0.8/bin/mallet import-file --preserve-case --keep-sequence --remove-stopwords --token-regex "\S+" --input C:\Users\user\AppData\Local\Temp\2\e1ba4a_corpus.txt --output C:\Users\user\AppData\Local\Temp\2\e1ba4a_corpus.mallet' returned non-zero exit status 1.
【问题讨论】: