From 3a008ea0888654c8a73b6c107c73736836e06440 Mon Sep 17 00:00:00 2001 From: andrewso <9V5f1FkzI2LD> Date: Mon, 12 Oct 2020 16:51:05 +0100 Subject: [PATCH] [12.10.20] Testing - not allowing over 80% Neutral Tweets to be passed, and removed some logging noise --- src/tweets/collector.py | 8 +++++++- src/utils/sentimentAnalyser.py | 2 +- src/utils/spamFilter.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tweets/collector.py b/src/tweets/collector.py index 4f4ec1d..b138ebf 100644 --- a/src/tweets/collector.py +++ b/src/tweets/collector.py @@ -135,7 +135,7 @@ def processTweet(text, type): if callSpamFilter(cleanedTweet) != 'spam': pos, neu, neg, compound = callSentimentAnalyser(cleanedTweet) - if compound != 0.0: + if compound != 0.0 | neu <= 0.8: hourTweet = {'pos': pos, 'neu': neu, 'neg': neg, 'compound': compound, 'type': type} hourStack.append(hourTweet) @@ -146,10 +146,16 @@ def processTweet(text, type): def collector(hashtag): log("Thread Start...", 'INFO') + schedule.clear("collectTweets") + + global timeF + timeF = timeFunction() streamer = Streamer() streamer.stream_tweets(hashtag) + schedule.every().hour.at(timeF).do(createHourJob).tag("collectTweets") + def timeFunction(): global timeF diff --git a/src/utils/sentimentAnalyser.py b/src/utils/sentimentAnalyser.py index 11da95d..1d9aec8 100644 --- a/src/utils/sentimentAnalyser.py +++ b/src/utils/sentimentAnalyser.py @@ -10,7 +10,7 @@ class keys(): self.sentiment_analyser_uri = os.getenv("SENTIMENT_URL") def callSentimentAnalyser(tweet): - log("Calling Sentiment Analyser for [{}]".format(tweet), 'INFO') + # log("Calling Sentiment Analyser for [{}]".format(tweet), 'INFO') try: uri = keys().sentiment_analyser_uri + "/sentiment?tweet="+tweet response = requests.request("GET", uri) diff --git a/src/utils/spamFilter.py b/src/utils/spamFilter.py index 09030e9..9a0ba63 100644 --- a/src/utils/spamFilter.py +++ b/src/utils/spamFilter.py @@ -16,7 +16,7 @@ def callSpamFilter(tweet): response = json.loads(response.text) - log("Spam Filter result for [{}] is [{}]".format(tweet, response["result"]), 'INFO') + # log("Spam Filter result for [{}] is [{}]".format(tweet, response["result"]), 'INFO') return response["result"] except: