问题描述
我遵循了这里的槌 https://www.youtube.com/watch?v=TgXLq1XIdA0&t=823s 教程。 但是,运行python脚本后出现此错误。
Traceback (most recent call last):
File "tm.py",line 38,in <module>
lda_model = gensim.models.wrappers.ldamallet.LdaMallet(
File "C:\Users\mmb\anaconda3\lib\site-packages\gensim\models\wrappers\ldamallet.py",line 126,in __init__
self.train(corpus)
File "C:\Users\mmb\anaconda3\lib\site-packages\gensim\models\wrappers\ldamallet.py",line 279,in train
self.word_topics = self.load_word_topics()
File "C:\Users\mmb\anaconda3\lib\site-packages\gensim\models\wrappers\ldamallet.py",line 337,in load_word_topics
with utils.smart_open(self.fstate()) as fin:
File "C:\Users\mmb\anaconda3\lib\site-packages\smart_open\smart_open_lib.py",line 138,in smart_open
return file_smart_open(parsed_uri.uri_path,mode)
File "C:\Users\mmb\anaconda3\lib\site-packages\smart_open\smart_open_lib.py",line 642,in file_smart_open
return compression_wrapper(open(fname,mode),fname,line 630,in compression_wrapper
return make_closing(GzipFile)(file_obj,mode)
File "C:\Users\mmb\anaconda3\lib\gzip.py",line 173,in __init__
fileobj = self.myfileobj = builtins.open(filename,mode or 'rb')
TypeError: expected str,bytes or os.PathLike object,not _io.BufferedReader
错误发生在 lda_mallet 模型的创建过程中。
mallet_path = os.path.join('C:\mallet','bin','mallet')
# create the mallet modeling object
lda_model = gensim.models.wrappers.ldamallet.LdaMallet(
mallet_path,corpus=processed_corpus,id2word=corpus_dictionary,num_topics=number_of_topics,optimize_interval=10,prefix='fed_'
)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)