1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-22 08:12:27 +00:00

Added entry to example plugin

This commit is contained in:
J. Fernando Sánchez 2015-10-08 19:16:56 +02:00
parent ed22679e7c
commit 94d82238b8
2 changed files with 15 additions and 8 deletions

View File

@ -1,5 +1,5 @@
from senpy.plugins import SentimentPlugin from senpy.plugins import SentimentPlugin
from senpy.models import Response from senpy.models import Response, Entry
import logging import logging
@ -13,5 +13,12 @@ class ExamplePlugin(SentimentPlugin):
% self._info.get('custom_attribute')) % self._info.get('custom_attribute'))
def analyse(self, *args, **kwargs): def analyse(self, *args, **kwargs):
logger.warn('Analysing with the example') logger.warn('Analysing with the example.')
return Response() logger.warn('The answer to this response is: %s.' % kwargs['parameter'])
resp = Response()
ent = Entry(kwargs['input'])
ent['example:reversed'] = kwargs['input'][::-1]
ent['example:the_answer'] = kwargs['parameter']
resp.entries.append(ent)
return resp

View File

@ -5,11 +5,11 @@
"author": "@balkian", "author": "@balkian",
"version": "0.1", "version": "0.1",
"extra_params": { "extra_params": {
"timeout": { "parameter": {
"@id": "timeout_sleep", "@id": "parameter",
"aliases": ["timeout", "to"], "aliases": ["parameter", "param"],
"required": false, "required": true,
"default": 0 "default": 42
} }
}, },
"custom_attribute": "42" "custom_attribute": "42"