I have the following code snippet which I created with the help of this tutorial for unsupervised sentiment analysis purposes:
sent = [row for row in file_model.message]
phrases = Phrases(sent, min_count=1, progress_per=50000)
bigram = Phraser(phrases)
sentences = bigram[sent]
sentences[1]
file_export = file_model.copy()
file_export['old_message'] = file_export.message
file_export.old_message = file_export.old_message.str.join(' ')
file_export.message = file_export.message.apply(lambda x: ' '.join(bigram[x]))
file_export.to_csv('cleaned_dataset.csv', index=False)
Since now I want to have bigrams as well as trigrams, I tried it by adjusting it to:
sent = [row for row in file_model.message]
phrases = Phrases(sent, min_count=1, progress_per=50000)
bigram = Phraser(phrases)
trigram = Phraser(bigram[phrases])
sentences = trigram[sent]
sentences[1]
file_export = file_model.copy()
file_export['old_message'] = file_export.message
file_export.old_message = file_export.old_message.str.join(' ')
file_export.message = file_export.message.apply(lambda x: ' '.join(trigram[x]))
file_export.to_csv('cleaned_dataset.csv', index=False)
But when I run this, I get TypeError: 'int' object is not iterable which I assume refers to my adjustment to trigram = Phraser(bigram[phrases]). I am using gensim 4.1.2.
Unfortunately, I have no computer science background and solutions I find online don't help out.