简体   繁体   English

LDA Mallet Gensim CalledProcessError

[英]LDA Mallet Gensim CalledProcessError

Seems like many people are having issues with Mallet.似乎很多人都对 Mallet 有问题。

import os
from gensim.models.wrappers import LdaMallet

os.environ.update({'MALLET_HOME':r'C:/Users/myusername/Desktop/Topic_Modelling/mallet-2.0.8'})

mallet_path = r'C:/Users/myusername/Desktop/Topic_Modelling/mallet-2.0.8/bin/mallet' 

model = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus,num_topics=num_topics, id2word=id2word)

Getting the following errors:得到以下错误:

/bin/sh: C:/Users/myusername/Desktop/Topic_Modelling/mallet-2.0.8/bin/mallet.bat: No such file or directory

CalledProcessError: Command 'C:/Users/myusername/Desktop/Topic_Modelling/mallet-2.0.8/bin/mallet.bat import-file --preserve-case --keep-sequence --remove-stopwords --token-regex "\S+" --input /var/folders/ml/lxzrtxwn02vbvq65c80g1b640000gn/T/c52cdc_corpus.txt --output /var/folders/ml/lxzrtxwn02vbvq65c80g1b640000gn/T/c52cdc_corpus.mallet' returned non-zero exit status 127.

I downloaded mallet from http://mallet.cs.umass.edu/dist/mallet-2.0.8.zip and unzipped it in my directory.我从http://mallet.cs.umass.edu/dist/mallet-2.0.8.zip下载了 mallet 并将其解压缩到我的目录中。 I've tried running the command in the error in the terminal and I'm getting the same 'no such file found' error, but it's there in my directory?我试过在终端的错误中运行命令,但我得到了同样的“找不到这样的文件”错误,但它在我的目录中吗?

I've also followed this: https://ps.au.dk/fileadmin/ingen_mappe_valgt/installing_mallet.pdf我也跟着这个: https : //ps.au.dk/fileadmin/ingen_mappe_valgt/installing_mallet.pdf

When I go to the directory via command line and type ./bin/mallet I get a whole bunch of commands, which according to the instructions, is what I'm looking for to know that it's been installed ok.当我通过命令行进入目录并输入./bin/mallet我得到了一大堆命令,根据说明,我正在寻找知道它是否安装正常的命令。

I'm running the following on MacOS我在 MacOS 上运行以下程序

  • Python==3.9.6 Python==3.9.6
  • gensim==3.8.3 gensim==3.8.3

Anyone have any ideas?谁有想法?

As silly as this sounds, I resolved this by changing the path to:这听起来很愚蠢,我通过将路径更改为:

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

mallet_path = r'mallet-2.0.8/bin/mallet' 

So if you have the mallet directory in the same one as where your code is, this will work!因此,如果您的 mallet 目录与您的代码所在的目录相同,那么这将起作用!

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

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