'Preprocesses tweets to remove  URLs,
RTs, extra whitespaces and replace hashtags
with their definitions.'

@staticmethod
def preprocess_tweet(tweet):

    import re
    tagdef = S3Msg.tagdef
    tweet = tweet.lower()
    tweet = re.sub('((www\\.[\\s]+)|(https?://[^\\s]+))', '', tweet)
    tweet = re.sub('@[^\\s]+', '', tweet)
    tweet = re.sub('[\\s]+', '    ', tweet)
    tweet = re.sub('#([^\\s]+)', (lambda m: tagdef(m.group(0))), tweet)
    tweet = tweet.strip('\'"')
    return tweet
