def process(self, arrayOfTweets): for i, tweet in enumerate(arrayOfTweets): tweet['country'] = deep_fetch(tweet, 'place.country') place_type = deep_fetch(tweet, 'place.place_type') if place_type == 'city': tweet['city'] = deep_fetch(tweet, 'place.name') tweet['country_code'] = deep_fetch(tweet, 'place.country_code') tweet['bounding_box'] = deep_fetch(tweet, 'place.bounding_box.coordinates') self.random_coord(tweet)
def process(self, arrayOfTweets): for i, tweet in enumerate(arrayOfTweets): tweet['country'] = deep_fetch(tweet, 'place.country') place_type = deep_fetch(tweet, 'place.place_type') if place_type == 'city': tweet['city'] = deep_fetch(tweet, 'place.name') tweet['country_code'] = deep_fetch(tweet, 'place.country_code') tweet['bounding_box'] = deep_fetch( tweet, 'place.bounding_box.coordinates') self.random_coord(tweet)
def _map_(self, item): pull_mentions = lambda m : m['screen_name'] pull_hashtags = lambda m : m['text'] item['location'] = deep_fetch(item, 'user.location') item['avitar'] = deep_fetch(item, 'user.profile_image_url') item['folower_count'] = deep_fetch(item, 'user.followers_count') mentions = deep_fetch(item,'entities.user_mentions') hashtags = deep_fetch(item,'entities.hashtags') if isinstance(mentions, list): item['mentions'] = map(pull_mentions, mentions) if isinstance(hashtags, list): item['hashtags'] = map(pull_hashtags, hashtags) return item
def process(self, arrayOfTweets): for i, tweet in enumerate(arrayOfTweets): copy = tweet.copy() tweet.clear() for field, lookup in self.fields.iteritems(): tweet[field] = deep_fetch(copy, lookup)