def prepare()

in social-media/scanner.py [0:0]


def prepare(tweet):
    '''Prepares the tweet as a flat JSON object that matches the schema
    expected by the ML model it will be sent to.'''
    logger.info('Preparing tweet %s', tweet)
    ans = {
        'description': tweet['user']['description'],
        'favourites_count': str(tweet['user']['favourites_count']),
        'followers_count': str(tweet['user']['followers_count']),
        'friends_count': str(tweet['user']['friends_count']),
        'geo_enabled': str(tweet['user']['geo_enabled']),
        'screen_name': tweet['user']['screen_name'],
        'sid': tweet['id_str'],
        'statuses_count': str(tweet['user']['statuses_count']),
        'text': tweet['text'],
        'uid': tweet['user']['id_str'],
        'user.name': tweet['user']['name'],
        'verified': str(tweet['user']['verified'])
    }
    ans = json.dumps(ans)
    logger.debug('Prepared JSON object %s', ans)
    return ans