mirror of
https://github.com/gsi-upm/senpy
synced 2025-08-24 02:22:20 +00:00
cambios
This commit is contained in:
@@ -10,23 +10,15 @@ from senpy.models import Results, Entry, Sentiment,Error
|
||||
|
||||
class DaedalusPlugin(SentimentPlugin):
|
||||
|
||||
def activate(self, *args, **kwargs):
|
||||
pass
|
||||
def analyse_entry(self, entry, params):
|
||||
|
||||
def deactivate(self, *args, **kwargs):
|
||||
self.close()
|
||||
|
||||
|
||||
def analyse(self, **params):
|
||||
|
||||
txt = params["input"]
|
||||
txt = entry.get("text",None)
|
||||
model = params["model"] # 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'}
|
||||
r = requests.post(api, params=parameters)
|
||||
print(r.text)
|
||||
|
||||
value = r.json().get('score_tag', None)
|
||||
if not value:
|
||||
@@ -42,10 +34,8 @@ class DaedalusPlugin(SentimentPlugin):
|
||||
elif 'P' in value:
|
||||
polarity = 'marl:Positive'
|
||||
polarityValue = 1
|
||||
entry = Entry(id="Entry0",nif_isString=txt)
|
||||
|
||||
opinion = Sentiment(id="Opinion0",marl__hasPolarity=polarity,marl__polarityValue = polarityValue)
|
||||
opinion["prov:wasGeneratedBy"] = self.id
|
||||
entry.sentiments = []
|
||||
entry.sentiments.append(opinion)
|
||||
response.entries.append(entry)
|
||||
return response
|
||||
|
||||
yield entry
|
Reference in New Issue
Block a user