I have ‘n’ number of tweets in a list with different languages. Now using TextBlob I want to translate languages of all the Tweets into English and I want to save it into a new variable.
I am stuck in the process of saving the language translated tweets into a new variable.
The code which I have tried to execute is given below.
Python Code: (where ‘L’ consists of n number of tweets and it is of list type)
text=
for i in L:
blob = TextBlob(i)
if blob.detect_language() != ‘en’:
text.append(blob.translate(to =‘en’))
else:
text.append(blob)
instead of “text.append” if I use the “print” statement, then the code works and prints all the language translated tweets. But my problem is, I am not getting how to retrieve these translated tweets for further analysis. Kindly suggest me with any possible solutions.
1 post - 1 participant