Привет! Я использовал gensim для моделирования тем, использовал Маллет и выполнял этот код. Я распаковал молоток на диске c, как показано, и также установил команду среды MALLET_HOME
.Код, который я выполнял:
mallet_path = r'c:/mallet-2.0.8/bin/mallet'
ldamallet = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus,
num_topics=20, id2word=id2word)
, это дает мне такую ошибку
CalledProcessError Traceback (most recent call last)
<ipython-input-58-6e0dbb876ee6> in <module>()
----> 1 ldamallet = gensim.models.wrappers.LdaMallet(mallet_path,
corpus=corpus,
num_topics=20, id2word=id2word)
~\AppData\Local\Continuum\anaconda3\lib\site-
packages\gensim\models\wrappers\ldamallet.py in __init__(self, mallet_path,
corpus, num_topics, alpha, id2word, workers, prefix, optimize_interval,
iterations, topic_threshold)
124 self.iterations = iterations
125 if corpus is not None:
--> 126 self.train(corpus)
127
128 def finferencer(self):
~\AppData\Local\Continuum\anaconda3\lib\site-
packages\gensim\models\wrappers\ldamallet.py in train(self, corpus)
265
266 """
--> 267 self.convert_input(corpus, infer=False)
268 cmd = self.mallet_path + ' train-topics --input %s --num-topics
%s --alpha %s --optimize-interval %s '\
269 '--num-threads %s --output-state %s --output-doc-topics %s -
-output-topic-keys %s '\
~\AppData\Local\Continuum\anaconda3\lib\site-
packages\gensim\models\wrappers\ldamallet.py in convert_input(self, corpus,
infer, serialize_corpus)
254 cmd = cmd % (self.fcorpustxt(), self.fcorpusmallet())
255 logger.info("converting temporary corpus to MALLET format with
%s", cmd)
--> 256 check_output(args=cmd, shell=True)
257
258 def train(self, corpus):
~\AppData\Local\Continuum\anaconda3\lib\site-packages\gensim\utils.py in
check_output(stdout, *popenargs, **kwargs)
1804 error = subprocess.CalledProcessError(retcode, cmd)
1805 error.output = output
-> 1806 raise error
1807 return output
1808 except KeyboardInterrupt:`
CalledProcessError: Command 'c:\mallet-2.0.8\bin\mallet import-file --
preserve-case --keep-sequence --remove-stopwords --token-regex "\S+" --input
C:\Users\apath009\AppData\Local\Temp\d186ea_corpus.txt --output
C:\Users\apath009\AppData\Local\Temp\d186ea_corpus.mallet' returned non-zero
exit status 1.
Пожалуйста, помогите !!!