LDA木槌CalledProcessError [英] LDA Mallet CalledProcessError

查看:108
本文介绍了LDA木槌CalledProcessError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现以下代码:

I am trying to implement the following code:

import os
os.environ.update({'MALLET_HOME':r'c:/mallet-2.0.8/'})

mallet_path = 'C:\\mallet-2.0.8\\bin\\mallet'
ldamallet = gensim.models.wrappers.LdaMallet(mallet_path, corpus=bow, num_topics=20, id2word=dictionary)

但是,我不断收到此错误:

However, I keep getting this error:

CalledProcessError:命令'C:\ mallet-2.0.8 \ bin \ mallet导入文件--preserve-case --keep-sequence --remove-stopwords --token-regex"\ S +"-输入C :\ Users \ Joshua \ AppData \ Local \ Temp \ 98094d_corpus.txt-输出C:\ Users \ Joshua \ AppData \ Local \ Temp \ 98094d_corpus.mallet'返回非零退出状态1.

CalledProcessError: Command 'C:\mallet-2.0.8\bin\mallet import-file --preserve-case --keep-sequence --remove-stopwords --token-regex "\S+" --input C:\Users\Joshua\AppData\Local\Temp\98094d_corpus.txt --output C:\Users\Joshua\AppData\Local\Temp\98094d_corpus.mallet' returned non-zero exit status 1.

我以前能够在具有相同目录的笔记本电脑上执行此代码,但无法在我的PC(我当前正在运行python的计算机)上执行.

I previously was able to execute this code on my laptop with the same directories yet it does not execute on my PC (where I am currently running python).

有人可以让我知道我在做什么错吗?

Could someone please let me know what I am doing wrong?

推荐答案

我遇到了类似的错误.仔细检查您是否已安装Java,并且文件路径正在调用Java.我必须编辑在槌文件夹C:\ mallet \ mallet-2.0.8 \ bin中找到的mallet.bat文件,如下所示:

I ran into a similar error. Double check that you have java installed and that the file path is calling java. I had to edit my mallet.bat file found in the mallet folder C:\mallet\mallet-2.0.8\bin like this:

@echo off

rem This batch file serves as a wrapper for several
rem  MALLET command line tools.

if not "%MALLET_HOME%" == "" goto gotMalletHome

echo MALLET requires an environment variable MALLET_HOME.
goto :eof

:gotMalletHome

set MALLET_CLASSPATH=C:\mallet\mallet-2.0.8\class;C:\mallet\mallet-2.0.8\lib\mallet-deps.jar
set MALLET_MEMORY=1G
set MALLET_ENCODING=UTF-8

set CMD=%1
shift

set CLASS=
if "%CMD%"=="import-dir" set CLASS=cc.mallet.classify.tui.Text2Vectors
if "%CMD%"=="import-file" set CLASS=cc.mallet.classify.tui.Csv2Vectors
if "%CMD%"=="import-svmlight" set CLASS=cc.mallet.classify.tui.SvmLight2Vectors
if "%CMD%"=="info" set CLASS=cc.mallet.classify.tui.Vectors2Info
if "%CMD%"=="train-classifier" set CLASS=cc.mallet.classify.tui.Vectors2Classify
if "%CMD%"=="classify-dir" set CLASS=cc.mallet.classify.tui.Text2Classify
if "%CMD%"=="classify-file" set CLASS=cc.mallet.classify.tui.Csv2Classify
if "%CMD%"=="classify-svmlight" set CLASS=cc.mallet.classify.tui.SvmLight2Classify
if "%CMD%"=="train-topics" set CLASS=cc.mallet.topics.tui.TopicTrainer
if "%CMD%"=="infer-topics" set CLASS=cc.mallet.topics.tui.InferTopics
if "%CMD%"=="evaluate-topics" set CLASS=cc.mallet.topics.tui.EvaluateTopics
if "%CMD%"=="prune" set CLASS=cc.mallet.classify.tui.Vectors2Vectors
if "%CMD%"=="split" set CLASS=cc.mallet.classify.tui.Vectors2Vectors
if "%CMD%"=="bulk-load" set CLASS=cc.mallet.util.BulkLoader
if "%CMD%"=="run" set CLASS=%1 & shift

if not "%CLASS%" == "" goto gotClass

echo Mallet 2.0 commands: 
echo   import-dir        load the contents of a directory into mallet instances (one per file)
echo   import-file       load a single file into mallet instances (one per line)
echo   import-svmlight   load a single SVMLight format data file into mallet instances (one per line)
echo   info              get information about Mallet instances
echo   train-classifier  train a classifier from Mallet data files
echo   classify-dir      classify data from a single file with a saved classifier
echo   classify-file     classify the contents of a directory with a saved classifier
echo   classify-svmlight classify data from a single file in SVMLight format
echo   train-topics      train a topic model from Mallet data files
echo   infer-topics      use a trained topic model to infer topics for new documents
echo   evaluate-topics   estimate the probability of new documents given a trained model
echo   prune             remove features based on frequency or information gain
echo   split             divide data into testing, training, and validation portions
echo   bulk-load         for big input files, efficiently prune vocabulary and import docs
echo Include --help with any option for more information


goto :eof

:gotClass

set MALLET_ARGS=

:getArg

if "%1"=="" goto run
set MALLET_ARGS=%MALLET_ARGS% %1
shift
goto getArg

:run

"C:\Program Files\Java\jdk-12\bin\java" -ea -Dfile.encoding=%MALLET_ENCODING% -classpath %MALLET_CLASSPATH% %CLASS% %MALLET_ARGS%

:eof

然后更改文件路径以反映此更改:

Then change your file path to reflect this change:

mallet_path = 'C:/mallet/mallet-2.0.8/bin/mallet.bat'

希望这会有所帮助:)

这篇关于LDA木槌CalledProcessError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆