twitter-text-python is a Tweet parser and formatter for Python. Amongst many things, the tasks that can be performed by this module are :
- reply : The username of the handle to which the tweet is bieng replied to.
- users : All the usernames mentioned in the tweet.
- tags : All the hashtags mentioned in the tweet.
- urls : All the URLs mentioned in the tweet.
- html : Adds hyperlinks to the fields mentioned above.
Example 1 :
The username being replied to is : twitter
All the usernames mentioned are : [‘twitter’, ‘TwitterIndia’]
All the hashtags mentioned are : [‘gfg’, ‘tweeple’]
All the URLs mentioned are : [‘https://twitter.com’]
Example 2 : We can also find the position of string (POS) by doing
include_spans = True.
All the usernames mentioned are : [(‘twitter’, (0, 8)), (‘TwitterIndia’, (130, 143))]
All the hashtags mentioned are : [(‘gfg’, (96, 100)), (‘tweeple’, (101, 109))]
All the URLs mentioned are : [(‘https://twitter.com’, (76, 95))]
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