import re


def get_text(tweet):
    """
    Helper function that retrieves full text of tweet from dictionary

    Parameters
    ----------
        tweet: (dict)
           data for individual tweet

    Returns
    -------
        text (str)
           non-abbreviated text of tweet
    """

    text = str()

    # search tweet dictionary to see if extended tweet is available
    if 'extended_tweet' in str(tweet):
        if 'extended_tweet' in tweet.keys():
            text = tweet['extended_tweet']['full_text']
        else:
            if 'retweeted_status' in tweet.keys():
                if 'extended_tweet' in str(tweet['retweeted_status']):
                    if 'extended_tweet' in tweet['retweeted_status'].keys():
                        text = (tweet
                                    ['retweeted_status']
                                    ['extended_tweet']
                                    ['full_text'])
                    else:
                        if 'quoted_status' in (tweet
                                                   ['retweeted_status']
                                               ).keys():
                            if 'extended_tweet' in (tweet
                                                        ['retweeted_status']
                                                        ['quoted_status']
                                                    ).keys():
                                text = (tweet
                                            ['retweeted_status']
                                            ['quoted_status']
                                            ['extended_tweet']
                                            ['full_text'])   
    else:
        try:
            text = tweet['text']
        except:
            pass

    # clean text
    text = (text.replace('&amp', 'and')
               .replace('\n', ' ')
               .replace('RT ', ''))
    text = re.sub(r'http\S+', '', text)

    return text