#!/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 for [{}]".format(tweet), 'INFO') try: uri = keys().sentiment_analyser_uri + "/sentiment?tweet="+tweet response = requests.request("GET", uri) response = json.loads(response.text) 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