Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3f8ba4cec | ||
|
|
da43817926 | ||
|
|
17bd1399cc |
@ -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)
|
||||
|
||||
@ -224,6 +224,7 @@ def collectorMain(hashtag):
|
||||
for i in range(len(hashtag)):
|
||||
Thread(target=collector, args=[hashtag[i]]).start()
|
||||
|
||||
sleep(2)
|
||||
createHourJob()
|
||||
|
||||
while True:
|
||||
|
||||
@ -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
|
||||
@ -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 ""
|
||||
Loading…
x
Reference in New Issue
Block a user