def word_data(self): '''Word counts and neighbors for all tweets.''' all_text = "" for user in self._population: tweets = user['tweets'] for tweet in tweets: all_text += tweet['text'] counter = WordCounter(all_text) word_data = counter.get_word_data() return word_data
def all_word_data(self): '''Returns word counts and neighbors for all of a user's tweets.''' for member in self._population: if member['uid'] == self._uid: found = True break else: found = False if not found: raise Exception('User not in population: %s' % self._uid) all_text = "" for tweet in user['tweets']: all_text += ' ' + tweet['text'] counter = WordCounter(all_text) word_data = counter.get_word_data() return word_data
def individual_word_data(self): '''Word counts and neighbors for each of a user's tweets.''' for member in self._population: if member['uid'] == self._uid: found = True break else: found = False if not found: raise Exception('User not in population: %s' % self._uid) tweet_data = [] for tweet in user['tweets']: text = tweet['text'] counter = WordCounter(text) word_data = counter.get_word_data() tweet_data.append({'id':tweet['id'], 'text':text, \ 'word_data':word_data}) return tweet_data
def words_by_day(self): word_counts = {} for day, tweets in self._tweets_by_day.items(): tweet_text = '' for tweet in tweets: tweet_text += tweet['text'] day_counts = WordCounter(tweet_text).get_word_data() word_counts[day] = day_counts return word_counts