Compare commits

...

2 Commits

Author SHA1 Message Date
andrewso
b3f8ba4cec [15.10.20] Testing 2020-10-15 20:19:39 +01:00
andrewso
da43817926 [15.10.20] Testing 2020-10-15 20:15:55 +01:00
3 changed files with 13 additions and 8 deletions

View File

@ -40,7 +40,7 @@ def sendToArtemis(syncId, pos, neu, neg, compound, type):
strippedTimestamp = timestamp.replace(minute=0, second=0, microsecond=0)
timestamp = strippedTimestamp.strftime('%Y-%m-%dT%H:%M:%S')
message = { "timestamp" : timestamp, "syncId": syncId, "pos" : pos, "neu" : neu, "neg" : neg, "compound" : compound, "type": type }
message = { "timestamp" : timestamp, "syncId": str(syncId), "pos" : pos, "neu" : neu, "neg" : neg, "compound" : compound, "type": type }
messageJson = json.dumps(message, indent = 4)

View File

@ -10,10 +10,13 @@ class keys():
self.sentiment_analyser_uri = os.getenv("SENTIMENT_URL")
def callSentimentAnalyser(tweet, syncId):
# log("Calling Sentiment Analyser for [{}]".format(tweet), 'INFO')
headers = {
"content-type":"text",
"X-CRYPTO-Sync-ID" : str(syncId)
}
try:
uri = keys().sentiment_analyser_uri + "/sentiment?tweet="+tweet
response = requests.get(uri, headers={"X-CRYPTO-Sync-ID" : syncId})
response = requests.request("GET", url=uri, headers=headers)
response = json.loads(response.text)
@ -21,5 +24,5 @@ def callSentimentAnalyser(tweet, syncId):
return scores["pos"], scores["neu"], scores["neg"], scores["compound"]
except:
log("Could not call Sentiment Analyser Service", 'ERR')
log("Could not call Sentiment Analyser Service with syncId of [{}]".format(syncId), 'ERR', syncId)
return 0, 0, 0, 0

View File

@ -10,15 +10,17 @@ class keys():
self.spamFilter_uri = os.getenv("FILTER_URL")
def callSpamFilter(tweet, syncId):
headers = {
"content-type":"text",
"X-CRYPTO-Sync-ID" : str(syncId)
}
try:
uri = keys().spamFilter_uri + "/predict?tweet="+tweet
response = requests.get(uri, headers={"X-CRYPTO-Sync-ID" : syncId})
response = requests.request("GET", url=uri, headers=headers)
response = json.loads(response.text)
# log("Spam Filter result for [{}] is [{}]".format(tweet, response["result"]), 'INFO')
return response["result"]
except:
log("Could not call spam filter service", 'ERR')
log("Could not call spam filter service with syncId of [{}]".format(syncId), 'ERR', syncId)
return ""