23 lines
629 B
Python
23 lines
629 B
Python
#!/usr/bin/env python
|
|
|
|
import json, requests, os
|
|
|
|
from src.utils.jsonLogger import log
|
|
|
|
class keys():
|
|
|
|
def __init__(self):
|
|
self.sentiment_analyser_uri = os.getenv("SENTIMENT_URL")
|
|
|
|
def callSentimentAnalyser(tweet):
|
|
log("Calling Sentiment Analyser", 'INFO')
|
|
try:
|
|
uri = keys().sentiment_analyser_uri + "/sentiment?tweet="+tweet
|
|
response = requests.request("GET", uri)
|
|
|
|
scores = response["result"]["Score"]
|
|
|
|
return scores["pos"], scores["neu"], scores["neg"], scores["compound"]
|
|
except:
|
|
log("Could not call Sentiment Analyser Service", 'ERR')
|
|
return 0, 0, 0, 0 |