def fetch_data(self, tup): """ Get tweets for given user """ user, label = tup # Get relevant tweet text for that user tweets = utils.get_tweet_list(self.api, user, self.max_tweets) # Construct list of (tweets {data}, party {label}) return [ (t, label) for t in tweets if t ]
def run(cfg_name, load=False, max_tweets=DEFAULT_MAX_TWEETS): """ Run program """ api = initialise_tweepy(cfg_name) m = model.Model(api=api, max_tweets=max_tweets) if load: print("Loading model...") cl = utils.load_model() else: print("Training fresh model...") cl = m.generate_model() while True: # Get users tweets and classify handle = get_user_input() if handle: tweet_list = utils.get_tweet_list(api, handle, max_tweets) p = cl.classify(tweet_list) print("Party: {0}".format(p)) else: exit("Bye!")