Error when implementing gensim.LdaMallet

老子叫甜甜 提交于 2019-12-04 09:38:55

This can happen for two reasons: 1. You have space in your mallet path. 2. There is no MALLET_HOME environment variable.

  1. Make sure that mallet properly works from command-line.
  2. Look to your folder 'c:\users\brlu\appdata\local\temp\...' if there are some files, you can deduce at which step mallet-wrapper fails. Try this step at command line.

In my case I forgot to import gensim's mallet wrapper. The following code resolved the error.

import os
from gensim.models.wrappers import LdaMallet

os.environ['MALLET_HOME'] = 'C:/.../mallet-2.0.8/'

A more detailed explanation can be found here: https://github.com/RaRe-Technologies/gensim/issues/2137

user1520759

I had similar problems with gensim + MALLET on Windows:

  1. Make sure that MALLET_HOME is set
  2. Escape slashes when set mallet_path in Python

    mallet_path = 'c:\\mallet-2.0.7\\bin\\mallet'
    LDA_model = gensim.models.LdaMallet(mallet_path, ...
    
  3. Also, it might be useful to modify line 142 in Python\Lib\site-packages\gensim\models\ldamallet.py: change --token-regex '\S+' to --token-regex \"\S+\"

Hope it helps

Try the following

  1. import tempfile
  2. tempfile.tempdir='some_other_non_system_temp_directory'
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!