Python Tweepy – Getting the language of a tweet
In this article we will see how we can fetch the language of a tweet/status. The lang attribute of the Status object indicates the language of the status. The language is indicated in the language code example, English is en, Hindi is hi.
In order to get the language of the status, we have to do the following :
- Identify the status ID of the status from the GUI.
- Get the Status object of the status using the
get_status()method with the status ID.
- From this object, fetch the lang attribute present in it.
Example 1 : Consider the following status :
We will use the status ID to fetch the status. The status ID of the above mentioned status is 1272771459249844224.
The language of the status is : en
Example 2 : Consider the following status :
We will use the status ID to fetch the status. The status ID of the above mentioned status is 1273220141417816064.
The language of the status is : hi
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course