Classify Type Of Tweet (tweet/retweet/mention) Based On Tweet Text In Python
Pulling from a couple of different examples, I've been able to create a simple Python script that parses the JSON output from the Twitter Streaming API, and prints out the screen_n
Solution 1:
I don't have any python interpreter here, but it should be something similar to this:
import re
defurl_match(tweet):
match = re.match(r'RT\s@....+', tweet)
if match:
return"RT"else:
match = re.match(r'@....+', tweet)
if match:
return"mention"elsereturn"tweet"
Note: this will work for this classification, but if you want to retrieve usernames i.e. @USERNAME you will have to tweak this a little more.
Post a Comment for "Classify Type Of Tweet (tweet/retweet/mention) Based On Tweet Text In Python"