1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-09-20 22:01:41 +00:00
senpy/example-plugin/example.py

25 lines
807 B
Python
Raw Normal View History

2015-10-08 17:07:48 +00:00
from senpy.plugins import SentimentPlugin
2015-10-08 17:16:56 +00:00
from senpy.models import Response, Entry
2015-10-08 17:07:48 +00:00
import logging
logger = logging.getLogger(__name__)
class ExamplePlugin(SentimentPlugin):
def __init__(self, *args, **kwargs):
super(ExamplePlugin, self).__init__(*args, **kwargs)
logger.warn('%s: the answer to life, the universe and everything'
% self._info.get('custom_attribute'))
def analyse(self, *args, **kwargs):
2015-10-08 17:16:56 +00:00
logger.warn('Analysing with the example.')
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