I'm trying to generate a Latent Dirichlet Allocation model using 500 different txts. One part of my code is as follows:
from gensim.models import Phrases
from gensim import corpora, models
bigram = Phrases(docs, min_count=10)
trigram = Phrases(bigram[docs])
for idx in range(len(docs)):
for token in bigram[docs[idx]]:
if '_' in token:
# Token is a bigram, add to document.
docs[idx].append(token)
for token in trigram[docs[idx]]:
if '_' in token:
# Token is a bigram, add to document.
docs[idx].append(token)
And it gives me the following error:
File ".../scriptLDA.py", line 74, in <module>
docs[idx].append(token)
AttributeError: 'str' object has no attribute 'append'
Can someone fix it for me? Thanks!