python-3.x - 尝试使用 Gensim 运行 Mallet 时出现 subprocess.CalledProcessError
问题描述
我正在尝试使用 Gensim 和 Mallet(链接)进行主题建模。当我找到 mallet_path 然后尝试将其分配给 gensim 时,我收到错误 subprocess.CalledProcessError : returned non-zero exit status 1
并且系统提示我更新 Java(我已经完成了)。
关于如何解决它的任何提示?
mallet_path = '/Users/username/mallet-2.0.8/bin/mallet'
ldamallet = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, num_topics=20, id2word=id2word)
Traceback (most recent call last):
File "<pyshell#85>", line 1, in <module>
ldamallet = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, num_topics=20, id2word=id2word)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gensim/models/wrappers/ldamallet.py", line 132, in __init__
self.train(corpus)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gensim/models/wrappers/ldamallet.py", line 273, in train
self.convert_input(corpus, infer=False)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gensim/models/wrappers/ldamallet.py", line 262, in convert_input
check_output(args=cmd, shell=True)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gensim/utils.py", line 1918, in check_output
raise error
subprocess.CalledProcessError: Command '/Users/username/mallet-2.0.8/bin/mallet import-file --preserve-case --keep-sequence --remove-stopwords --token-regex "\S+" --input /var/folders/76/hdlh6w8d3nbb4m424wx3010w0000gn/T/adc98e_corpus.txt --output /var/folders/76/hdlh6w8d3nbb4m424wx3010w0000gn/T/adc98e_corpus.mallet' returned non-zero exit status 1.
解决方案
在 bin 目录中,使用文本编辑器打开 mallet 文件,然后增加 MEMORY 限制。它对我有用。
推荐阅读
- python - 为什么 Python 的内联类方法的行为与元类定义的方法不同
- java - 使用 countDownLatch 更新两个或多个 ProgressBar
- javascript - 如果文本输入在每个循环内,Svelte 组件不会使用新值重新渲染
- javascript - Dialogflow:获取一个数组中的所有文档 ID 的 firestore 集合(javascript 节点)
- python - TFIDF 与 Word2Vec
- java - WorkManager 不会按需初始化
- vue.js - 将 Bootstrap 4 与 NuxtJS 一起使用
- java - 使用外部应用程序编辑 pdf 不会覆盖现有文件
- python - 如何绘制文本簇?
- vue.js - 构建 Vue 组件并将其发布到 NPM