def update_data(self): newest_tweet = Mongo.collection.find({"module": "Pets"}).sort("published_at", pymongo.DESCENDING) if newest_tweet.count() > 0: since_id = newest_tweet[0]["tweet_id"] else: since_id = None dog_tweets = Tweet.search( "filter:safe seattle dog OR dog's OR dogs OR puppy OR pup OR pooch OR mutt", count=1000, since_id=since_id ) cat_tweets = Tweet.search( "filter:safe seattle cat OR cat's OR cats OR kitty OR kitten OR feline", count=1000, since_id=since_id ) for tweet in dog_tweets: Mongo.collection.insert_one({ "module": "Pets", "published_at": tweet.created_at, "content": tweet.text, "tweet_id": tweet.id, "score": 1 }) for tweet in cat_tweets: Mongo.collection.insert_one({ "module": "Pets", "published_at": tweet.created_at, "content": tweet.text, "tweet_id": tweet.id, "score": -1 }) return True
def update_data(self): newest_tweet = Mongo.collection.find({ "module": "Pets" }).sort("published_at", pymongo.DESCENDING) if newest_tweet.count() > 0: since_id = newest_tweet[0]["tweet_id"] else: since_id = None dog_tweets = Tweet.search( "filter:safe seattle dog OR dog's OR dogs OR puppy OR pup OR pooch OR mutt", count=1000, since_id=since_id) cat_tweets = Tweet.search( "filter:safe seattle cat OR cat's OR cats OR kitty OR kitten OR feline", count=1000, since_id=since_id) for tweet in dog_tweets: Mongo.collection.insert_one({ "module": "Pets", "published_at": tweet.created_at, "content": tweet.text, "tweet_id": tweet.id, "score": 1 }) for tweet in cat_tweets: Mongo.collection.insert_one({ "module": "Pets", "published_at": tweet.created_at, "content": tweet.text, "tweet_id": tweet.id, "score": -1 }) return True
def update_data(self): newest_tweets = Mongo.collection.find({ "module": "Happy" }).sort("published_at", pymongo.DESCENDING) newest_tweets = list(newest_tweets) if newest_tweets: since_id = newest_tweets[0]["tweet_id"] else: since_id = None tweets = Tweet.search( "-filter:links lang:en -filter:retweets geocode:47.609403608607785,-122.35061645507812,16mi", count=10000, since_id=since_id) for tweet in tweets: tw = tweet.text.encode("latin-1", "ignore").decode("latin-1") algo_score = Algorithm.search(tw, self.algo_path) Mongo.collection.insert_one({ "module": "Happy", "published_at": tweet.created_at, "content": tweet.text, "tweet_id": tweet.id, "score": algo_score }) return True
def update_data(self): newest_tweets = Mongo.collection.find({"module": "Happy"}).sort("published_at", pymongo.DESCENDING) newest_tweets = list(newest_tweets) if newest_tweets: since_id = newest_tweets[0]["tweet_id"] else: since_id = None tweets = Tweet.search( "-filter:links lang:en -filter:retweets geocode:47.609403608607785,-122.35061645507812,16mi", count=10000, since_id=since_id ) for tweet in tweets: tw = tweet.text.encode("latin-1", "ignore").decode("latin-1") algo_score = Algorithm.search(tw, self.algo_path) Mongo.collection.insert_one({ "module": "Happy", "published_at": tweet.created_at, "content": tweet.text, "tweet_id": tweet.id, "score": algo_score }) return True
def update_data(self): newest_tweets = Mongo.collection.find({"module": "Weather"}).sort("published_at", pymongo.DESCENDING) newest_tweets = list(newest_tweets) if newest_tweets: since_id = newest_tweets[0]["tweet_id"] else: since_id = None tweets = Tweet.search( "-filter:links -filter:retweets geocode:47.609403608607785,-122.35061645507812,6mi", count=20000, since_id=since_id, ) for tweet in tweets: count_dictionary = {} for key in Weather.dictionary: count_dictionary[key] = 0 # without regex # for word in tweet.text.split(): # for key, value in Weather.dictionary.items(): # if word in value: # count_dictionary[key] += 1 # with regex for key, value_list in Weather.dictionary.items(): for value in value_list: if value == "wind": wind_mph = Weather.extract_wind_in_mph(tweet.text.lower()) # increment count only if wind is above threshhold if 25 <= wind_mph: count_dictionary[key] += 1 else: if re.search(value, tweet.text.lower()): count_dictionary[key] += 1 Mongo.collection.insert_one( { "module": "Weather", "published_at": tweet.created_at, "content": tweet.text, "tweet_id": tweet.id, "score": count_dictionary, } ) return True
def update_data(self): newest_tweets = Mongo.collection.find({ "module": "Weather" }).sort("published_at", pymongo.DESCENDING) newest_tweets = list(newest_tweets) if newest_tweets: since_id = newest_tweets[0]["tweet_id"] else: since_id = None tweets = Tweet.search( "-filter:links -filter:retweets geocode:47.609403608607785,-122.35061645507812,6mi", count=20000, since_id=since_id) for tweet in tweets: count_dictionary = {} for key in Weather.dictionary: count_dictionary[key] = 0 # without regex # for word in tweet.text.split(): # for key, value in Weather.dictionary.items(): # if word in value: # count_dictionary[key] += 1 # with regex for key, value_list in Weather.dictionary.items(): for value in value_list: if value == "wind": wind_mph = Weather.extract_wind_in_mph( tweet.text.lower()) # increment count only if wind is above threshhold if (25 <= wind_mph): count_dictionary[key] += 1 else: if re.search(value, tweet.text.lower()): count_dictionary[key] += 1 Mongo.collection.insert_one({ "module": "Weather", "published_at": tweet.created_at, "content": tweet.text, "tweet_id": tweet.id, "score": count_dictionary }) return True
def update_data(self): newest_tweets = Mongo.collection.find({ "module": "Time" }).sort("published_at", pymongo.DESCENDING) newest_tweets = list(newest_tweets) if newest_tweets: since_id = newest_tweets[0]["tweet_id"] else: since_id = None tweets = Tweet.search( "-filter:links -filter:retweets geocode:47.609403608607785,-122.35061645507812,300mi", count=2000, since_id=since_id) for tweet in tweets: time_instance = Time(module="Time", published_at=tweet.created_at, content=tweet.text, tweet_id=tweet.id) time_instance.assign_scores() time_instance.compute_time_guess() time_instance.check_accuracy() # time_instance.save() Mongo.collection.insert_one({ "module": time_instance.module, "published_at": time_instance.published_at, "content": time_instance.content, "tweet_id": time_instance.tweet_id, "score": time_instance.score, "time_guess": time_instance.time_guess, "actual_timeframe": time_instance.actual_timeframe, "accurate_guess": time_instance.accurate_guess }) return True
def update_data(self): newest_tweets = Mongo.collection.find({"module": "Influx"}).sort("published_at", pymongo.DESCENDING) if newest_tweets.count() > 0: since_id = newest_tweets[0]["tweet_id"] else: since_id = None tweets = Tweet.search("filter:safe -filter:retweets -if -? -considering -consideration -thinking -may -filter:links 'moving to seattle'",count = 20000, since_id=since_id) for tweet in tweets: Mongo.collection.insert_one({ "module": "Influx", "published_at": tweet.created_at, "content": tweet.text, "tweet_id": tweet.id, }) return len(tweets)
def update_data(self): newest_tweets = Mongo.collection.find({"module": "Time"}).sort("published_at", pymongo.DESCENDING) newest_tweets = list(newest_tweets) if newest_tweets: since_id = newest_tweets[0]["tweet_id"] else: since_id = None tweets = Tweet.search( "-filter:links -filter:retweets geocode:47.609403608607785,-122.35061645507812,300mi", count=2000, since_id=since_id ) for tweet in tweets: time_instance = Time( module = "Time", published_at = tweet.created_at, content = tweet.text, tweet_id = tweet.id ) time_instance.assign_scores() time_instance.compute_time_guess() time_instance.check_accuracy() # time_instance.save() Mongo.collection.insert_one({ "module": time_instance.module, "published_at" : time_instance.published_at, "content": time_instance.content, "tweet_id": time_instance.tweet_id, "score": time_instance.score, "time_guess": time_instance.time_guess, "actual_timeframe": time_instance.actual_timeframe, "accurate_guess": time_instance.accurate_guess }) return True
def update_data(self): newest_tweets = Mongo.collection.find({ "module": "Influx" }).sort("published_at", pymongo.DESCENDING) if newest_tweets.count() > 0: since_id = newest_tweets[0]["tweet_id"] else: since_id = None tweets = Tweet.search( "filter:safe -filter:retweets -if -? -considering -consideration -thinking -may -filter:links 'moving to seattle'", count=20000, since_id=since_id) for tweet in tweets: Mongo.collection.insert_one({ "module": "Influx", "published_at": tweet.created_at, "content": tweet.text, "tweet_id": tweet.id, }) return len(tweets)
def update_data(self): newest_tweet = Mongo.collection.find({"module": "Traffic"}).sort("published_at", pymongo.DESCENDING) if newest_tweet.count() > 0: since_id = newest_tweet[0]["tweet_id"] else: since_id = None print(since_id) tweets = Tweet.search( "seattle traffic", count=20000, since_id=since_id ) for tweet in tweets: Mongo.collection.insert_one({ "module": "Traffic", "published_at": tweet.created_at, "content": tweet.text, "tweet_id": tweet.id, "score": 1 }) return True
def recent_tweets(self): return Yelling(Tweet.search("yelling"))