gensim LdaMallet 提高 CalledProcessError,但在命令行运行 mallet 没有错误



标题几乎说明了一切。下面是一些测试代码:

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:UserssomebodyaplaceLDAmallet-2.0.binmallet'
gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, id2word=dictionary, num_topics=5, alpha=1)

这引发了以下错误(截断,因为其中大部分是不相关的堆栈信息(:

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

很好,超级棒,但是当我在cmd.exe或cygwin中运行该确切的命令时,没有错误,代码运行良好!我甚至可以测试返回码:"echo $?"在cygwin返回0。任何帮助非常感谢!

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

相关内容

  • 没有找到相关文章

最新更新