Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3f8ba4cec | ||
|
|
da43817926 |
@ -40,7 +40,7 @@ def sendToArtemis(syncId, pos, neu, neg, compound, type):
|
|||||||
strippedTimestamp = timestamp.replace(minute=0, second=0, microsecond=0)
|
strippedTimestamp = timestamp.replace(minute=0, second=0, microsecond=0)
|
||||||
timestamp = strippedTimestamp.strftime('%Y-%m-%dT%H:%M:%S')
|
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)
|
messageJson = json.dumps(message, indent = 4)
|
||||||
|
|
||||||
|
|||||||
@ -10,10 +10,13 @@ class keys():
|
|||||||
self.sentiment_analyser_uri = os.getenv("SENTIMENT_URL")
|
self.sentiment_analyser_uri = os.getenv("SENTIMENT_URL")
|
||||||
|
|
||||||
def callSentimentAnalyser(tweet, syncId):
|
def callSentimentAnalyser(tweet, syncId):
|
||||||
# log("Calling Sentiment Analyser for [{}]".format(tweet), 'INFO')
|
headers = {
|
||||||
|
"content-type":"text",
|
||||||
|
"X-CRYPTO-Sync-ID" : str(syncId)
|
||||||
|
}
|
||||||
try:
|
try:
|
||||||
uri = keys().sentiment_analyser_uri + "/sentiment?tweet="+tweet
|
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)
|
response = json.loads(response.text)
|
||||||
|
|
||||||
@ -21,5 +24,5 @@ def callSentimentAnalyser(tweet, syncId):
|
|||||||
|
|
||||||
return scores["pos"], scores["neu"], scores["neg"], scores["compound"]
|
return scores["pos"], scores["neu"], scores["neg"], scores["compound"]
|
||||||
except:
|
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
|
return 0, 0, 0, 0
|
||||||
@ -10,15 +10,17 @@ class keys():
|
|||||||
self.spamFilter_uri = os.getenv("FILTER_URL")
|
self.spamFilter_uri = os.getenv("FILTER_URL")
|
||||||
|
|
||||||
def callSpamFilter(tweet, syncId):
|
def callSpamFilter(tweet, syncId):
|
||||||
|
headers = {
|
||||||
|
"content-type":"text",
|
||||||
|
"X-CRYPTO-Sync-ID" : str(syncId)
|
||||||
|
}
|
||||||
try:
|
try:
|
||||||
uri = keys().spamFilter_uri + "/predict?tweet="+tweet
|
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)
|
response = json.loads(response.text)
|
||||||
|
|
||||||
# log("Spam Filter result for [{}] is [{}]".format(tweet, response["result"]), 'INFO')
|
|
||||||
|
|
||||||
return response["result"]
|
return response["result"]
|
||||||
except:
|
except:
|
||||||
log("Could not call spam filter service", 'ERR')
|
log("Could not call spam filter service with syncId of [{}]".format(syncId), 'ERR', syncId)
|
||||||
return ""
|
return ""
|
||||||
Loading…
x
Reference in New Issue
Block a user