From f9c4e4bd591a52fd1f5e990cdbcf86829e69acc1 Mon Sep 17 00:00:00 2001 From: militarpancho Date: Tue, 17 Jan 2017 11:49:01 +0100 Subject: [PATCH] Fixed some bugs --- affect/affect.py | 5 +++-- affect/affect.senpy | 2 +- meaningCloud/meaningCloud.py | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/affect/affect.py b/affect/affect.py index ec996f9..b0605e7 100644 --- a/affect/affect.py +++ b/affect/affect.py @@ -28,12 +28,13 @@ class unifiedPlugin(SentimentPlugin): logger.info('TXT:%s' % txt) endpoint = params["endpoint"] lang = params.get("language") - + key = params["apiKey"] sentiplug = params["sentiments-plugin"] s_params = params.copy() - s_params.update({'algo':sentiplug,'language':lang}) + s_params.update({'algo':sentiplug,'language':lang, 'meaningCloud-key':key}) senti_response = requests.get(endpoint, params=s_params).json() logger.info('SENTIPARAMS: %s' % s_params) + logger.info('SENTIRESPONSE: %s' % senti_response) if 'entries' not in senti_response: raise Error(senti_response) senti_response = Results(senti_response) diff --git a/affect/affect.senpy b/affect/affect.senpy index 2006b8e..9289ceb 100644 --- a/affect/affect.senpy +++ b/affect/affect.senpy @@ -30,7 +30,7 @@ "default": "http://senpy.cluster.gsi.dit.upm.es/api/" }, "apiKey": { - "aliases": ["apiKey","meaningCloud-key"], + "aliases": ["meaningCloud-key","apiKey"], "required": false } diff --git a/meaningCloud/meaningCloud.py b/meaningCloud/meaningCloud.py index 564dedd..2e04ff2 100644 --- a/meaningCloud/meaningCloud.py +++ b/meaningCloud/meaningCloud.py @@ -6,7 +6,7 @@ import os from os import path import time from senpy.plugins import SentimentPlugin, SenpyPlugin -from senpy.models import Results, Entry, Sentiment +from senpy.models import Results, Entry, Sentiment,Error class DaedalusPlugin(SentimentPlugin): @@ -24,13 +24,15 @@ class DaedalusPlugin(SentimentPlugin): model = params["model"] # general_es / general_es / general_fr api = 'http://api.meaningcloud.com/sentiment-2.1' lang = params.get("language") - #key = os.environ.get('DAEDALUS_KEY') key = params["apiKey"] parameters = {'key': key,'model': model,'lang': lang,'of': 'json','txt': txt,'src': 'its-not-a-real-python-sdk'} r = requests.post(api, params=parameters) print(r.text) value = r.json().get('score_tag', None) + if not value: + raise Error(r.json()) + #Senpy Response response = Results()