It is my first time to use mallet LDA. Basically, I downloaded the mallet-2.0.8 zip file and JDK. I installed JDK, extracted mallet-2.0.8 to a destination folder. I set the MALLET_HOME.
Here is my code
mallet_path='C:/Users/abc/mallet-2.0.8/bin/mallet'
ldamallet=gensim.models.wrappers.LdaMallet(mallet_path,corpus=corpus,num_topics=20,id2word=id2word)
However, it gives the error:
FILENOTFOUNDERROR[ERROR2]
I tried
mallet_path='C:\\Users\\abc\\mallet-2.0.8\\bin\\mallet'
and
mallet_path=r'C:\Users\abc\mallet-2.0.8\bin\mallet'
I got the same error msg.
I had the same issue and it was because I forgot to set the environment variable %MALLET_HOME%
import os
from gensim.models.wrappers import LdaMallet
os.environ['MALLET_HOME'] = 'C:/.../mallet-2.0.8/'
I was facing the same issue. The error I got was as follows:
IOError: [Errno 2] No such file or directory c:\\users\\...\\appdata\\local\\temp \\d36348_state.mallet.gz.
Each time I tried to run the code the prefix before the underscore would change but the error name would always end with the form "~Some Alphanumeric String~_state.mallet.gz".
I tried to understand the stack trace output in the console. The line just before this error line was as follows:
fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
I googled it and found this particular link. It is a github link where a person raised a different error, but the ending part of his error log was the same as mine. The solution to his error was an upgrade of his smart_open
module, which gensim
depends on, as the upgrade had fixed the issue. So i checked my smart_open
module version and it was 1.4.x
, last updated about a year and a half ago, so I upgraded it to the version 1.5.7
and the LdaMallet code works without a hiccup.
Please check if the problem on your end is being caused because of the same reasons.
Hope it helps!
P.S. I also updated my gensim
module alongside the smart_open
to version 3.4.