简体   繁体   English

gensim LdaMallet引发了CalledProcessError,但是在命令行运行mallet没有错误

[英]gensim LdaMallet raising CalledProcessError, but running mallet at command line runs with no error

The title pretty much says it all. 标题基本概括了所有内容。 Here's some test code: 这是一些测试代码:

import os
os.environ.update({'MALLET_HOME': r'C:/Users/somebody/a/place/LDA/mallet-2.0.8/',
                  'JAVA_HOME': r'C:/Program Files/Java/jdk1.8.0_131/'})

from gensim.corpora import mmcorpus, Dictionary
texts = [['human', 'interface', 'computer'],
 ['survey', 'user', 'computer', 'system', 'response', 'time'],
 ['eps', 'user', 'interface', 'system'],
 ['system', 'human', 'system', 'eps'],
 ['user', 'response', 'time'],
 ['trees'],
 ['graph', 'trees'],
 ['graph', 'minors', 'trees'],
 ['graph', 'minors', 'survey']]
dictionary = Dictionary(texts)
corpus = [dictionary.doc2bow(text) for text in texts]

import gensim

mallet_path = r'C:\Users\somebody\a\place\LDA\mallet-2.0.\bin\mallet'
gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, id2word=dictionary, num_topics=5, alpha=1)

This raises the following error (truncated, since most of it is irrelevant stack info): 这引发了以下错误(截断,因为大多数是不相关的堆栈信息):

CalledProcessError                        Traceback (most recent call last)
<ipython-input-99-7343c192afd1> in <module>()
      5 mallet_path = r'C:\Users\somebody\a\place\LDA\mallet-2.0.8\bin\mallet'
----> 6 gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, id2word=dictionary, num_topics=5, alpha=1)
.
.
.
CalledProcessError: Command 'C:\Users\somebody\a\place\LDA\mallet-2.0.8\bin\mallet import-file --preserve-case --keep-sequence --remove-stopwords --token-regex "\S+" --input C:\Users\somebody\AppData\Local\Temp\33b805_corpus.txt --output C:\Users\somebody\AppData\Local\Temp\33b805_corpus.mallet' returned non-zero exit status 1.

Fine, super, but when I go run that exact command in cmd.exe, or in cygwin, There is no error, the code runs just fine! 好,超级, 但是当我在cmd.exe或cygwin中运行那个确切的命令时,没有错误,代码运行得很好! I can even test the return code: "echo $?" 我甚至可以测试返回代码:“echo $?” in cygwin returns 0. Any help much appreciated! 在cygwin返回0.任何帮助非常感谢!

在bin目录中,使用文本编辑器打开mallet文件,然后更改MEMORY限制。

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

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