From cc112c5ac5f442683125c468d1b510e1dd9dc112 Mon Sep 17 00:00:00 2001 From: militarpancho Date: Wed, 1 Mar 2017 13:23:41 +0100 Subject: [PATCH] Addapted plugins to senpy 0.8.2 --- affect/README.md | 4 ++-- affect/affect.py | 8 -------- affect/affect.senpy | 1 - emotion-wnaffect/emotion-wnaffect.senpy | 7 ------- sentiment-140/sentiment-140.py | 2 +- sentiment-140/sentiment-140.senpy | 2 +- sentiment-basic/sentiment-basic.py | 2 +- sentiment-basic/sentiment-basic.senpy | 8 -------- sentiment-meaningCloud/sentiment-meaningCloud.py | 10 ++++++++-- sentiment-meaningCloud/sentiment-meaningCloud.senpy | 6 ------ 10 files changed, 13 insertions(+), 37 deletions(-) diff --git a/affect/README.md b/affect/README.md index ef18422..81b23d6 100644 --- a/affect/README.md +++ b/affect/README.md @@ -4,7 +4,7 @@ This plugin allows to choose sentiment and emotion plugins to retrieve a respons You can adjust the parameters of the plugin as follows: - - Sentiments plugins: EmoTextANEW, EmoTextWAF(only english) - - Emotions plugins: sentiText, vaderSentiment,meaningCloud(requires API KEY) + - Sentiments plugins: emotion-wnaffect, emotion-anew(only english) + - Emotions plugins: sentiment-tass, sentiment-vader,sentiment-meaningCloud(requires API KEY) - Endpoint: the endpoint where the used plugins are. (default: http://senpy.cluster.gsi.dit.upm.es/api/) - Language: english(en) or spanish(es) diff --git a/affect/affect.py b/affect/affect.py index 2b47317..48361af 100644 --- a/affect/affect.py +++ b/affect/affect.py @@ -14,14 +14,6 @@ logger = logging.getLogger(__name__) class unifiedPlugin(SentimentPlugin): - def activate(self, *args, **kwargs): - pass - - - def deactivate(self, *args, **kwargs): - self.save() - - def analyse(self, **kwargs): params = dict(kwargs) txt = params["input"] diff --git a/affect/affect.senpy b/affect/affect.senpy index dbdee4d..090e4eb 100644 --- a/affect/affect.senpy +++ b/affect/affect.senpy @@ -26,7 +26,6 @@ "endpoint": { "aliases": ["endpoint"], "required": true, - "options": ["http://senpy.cluster.gsi.dit.upm.es/api/"], "default": "http://senpy.cluster.gsi.dit.upm.es/api/" }, "apiKey": { diff --git a/emotion-wnaffect/emotion-wnaffect.senpy b/emotion-wnaffect/emotion-wnaffect.senpy index 3ad278b..320105c 100644 --- a/emotion-wnaffect/emotion-wnaffect.senpy +++ b/emotion-wnaffect/emotion-wnaffect.senpy @@ -4,13 +4,6 @@ "description": "Emotion classifier using WordNet-Affect to calculate the percentage of each emotion. This plugin classifies among 6 emotions: anger,fear,disgust,joy,sadness or neutral. The only available language is English (en)", "author": "@icorcuera @balkian", "version": "0.2", - "extra_params": { - "language": { - "aliases": ["language", "l"], - "required": true, - "default": "en" - } - }, "synsets_path": "/data/emotion-wnaffect/a-synsets.xml", "hierarchy_path": "/data/emotion-wnaffect/a-hierarchy.xml", "wn16_path": "/data/emotion-wnaffect/wordnet1.6/dict", diff --git a/sentiment-140/sentiment-140.py b/sentiment-140/sentiment-140.py index c7b08fe..dc345cb 100644 --- a/sentiment-140/sentiment-140.py +++ b/sentiment-140/sentiment-140.py @@ -7,7 +7,7 @@ from senpy.models import Results, Sentiment, Entry class Sentiment140Plugin(SentimentPlugin): - def analyse(self,entry,params): + def analyse_entry(self,entry,params): lang = params.get("language", "auto") res = requests.post("http://www.sentiment140.com/api/bulkClassifyJson", diff --git a/sentiment-140/sentiment-140.senpy b/sentiment-140/sentiment-140.senpy index 13a5a86..3766c98 100644 --- a/sentiment-140/sentiment-140.senpy +++ b/sentiment-140/sentiment-140.senpy @@ -1,7 +1,7 @@ { "name": "sentiment-140", "module": "sentiment-140", - "description": "What my plugin broadly does", + "description": "Sentiment classifier using rule-based classification for English and Spanish. This plugin uses sentiment140 data to perform classification. For more information: http://help.sentiment140.com/for-students/", "author": "@balkian", "version": "0.1", "extra_params": { diff --git a/sentiment-basic/sentiment-basic.py b/sentiment-basic/sentiment-basic.py index 6676612..d88270a 100644 --- a/sentiment-basic/sentiment-basic.py +++ b/sentiment-basic/sentiment-basic.py @@ -113,7 +113,7 @@ class SentiTextPlugin(SentimentPlugin): break - lang = params.get("language", "auto") + lang = params.get("language", "en") p = params.get("prefix", None) for i in scores: diff --git a/sentiment-basic/sentiment-basic.senpy b/sentiment-basic/sentiment-basic.senpy index 3868eef..d70360c 100644 --- a/sentiment-basic/sentiment-basic.senpy +++ b/sentiment-basic/sentiment-basic.senpy @@ -4,14 +4,6 @@ "description": "Sentiment classifier using rule-based classification for Spanish. Based on english to spanish translation and SentiWordNet sentiment knowledge. This is a demo plugin that uses only some features from the TASS 2015 classifier. To use the entirely functional classifier you can use the service in: http://senpy.cluster.gsi.dit.upm.es.", "author": "github.com/nachtkatze", "version": "0.1", - "extra_params": { - "language": { - "aliases": ["language", "l"], - "required": true, - "options": ["es"], - "default": "es" - } - }, "requirements": [ "nltk>=3.0.5", "scipy>=0.14.0", diff --git a/sentiment-meaningCloud/sentiment-meaningCloud.py b/sentiment-meaningCloud/sentiment-meaningCloud.py index 3ef9f59..1cc830e 100644 --- a/sentiment-meaningCloud/sentiment-meaningCloud.py +++ b/sentiment-meaningCloud/sentiment-meaningCloud.py @@ -13,11 +13,17 @@ class DaedalusPlugin(SentimentPlugin): def analyse_entry(self, entry, params): txt = entry.get("text",None) - model = params["model"] # general_es / general_es / general_fr + model = "general" # general_es / general_es / general_fr api = 'http://api.meaningcloud.com/sentiment-2.1' lang = params.get("language") key = params["apiKey"] - parameters = {'key': key,'model': model,'lang': lang,'of': 'json','txt': txt,'src': 'its-not-a-real-python-sdk'} + parameters = {'key': key, + 'model': model, + 'lang': lang, + 'of': 'json', + 'txt': txt, + 'src': 'its-not-a-real-python-sdk' + } r = requests.post(api, params=parameters) value = r.json().get('score_tag', None) diff --git a/sentiment-meaningCloud/sentiment-meaningCloud.senpy b/sentiment-meaningCloud/sentiment-meaningCloud.senpy index d029c35..827c233 100644 --- a/sentiment-meaningCloud/sentiment-meaningCloud.senpy +++ b/sentiment-meaningCloud/sentiment-meaningCloud.senpy @@ -11,12 +11,6 @@ "options": ["en","es"], "default": "en" }, - "model": { - "aliases": ["model"], - "required": true, - "options": ["general"], - "default": "general" - }, "apiKey":{ "aliases":["meaningCloud-key","apiKey"], "required":true