I followed the tutorial here for mallet https://www.youtube.com/watch?v=TgXLq1XIdA0&t=823s. However, I get this error after running the python script.
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, mode)
File "C:\Users\mmb\anaconda3\lib\site-packages\smart_open\smart_open_lib.py", 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
The error was during the creation of the lda_mallet model.
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_'
)
I fixed my own error. I created a new environment in anaconda and install gensim and other required libraries. It works!