1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-25 09:32:29 +00:00
senpy/example-plugin/example_plugin.py

37 lines
1.1 KiB
Python
Raw Normal View History

2019-04-04 10:56:46 +00:00
from senpy.plugins import AnalysisPlugin
2018-06-14 17:38:08 +00:00
from senpy.models import Response, Entry
2019-04-04 10:56:46 +00:00
class ExamplePlugin(AnalysisPlugin):
2018-06-14 17:38:08 +00:00
'''A *VERY* simple plugin that exemplifies the development of Senpy Plugins'''
name = "example-plugin"
author = "@balkian"
version = "0.1"
extra_params = {
"parameter": {
"@id": "parameter",
2019-04-04 10:56:46 +00:00
"description": "this parameter does nothing, it is only an example",
2018-06-14 17:38:08 +00:00
"aliases": ["parameter", "param"],
"required": True,
"default": 42
}
}
custom_attribute = "42"
2019-04-04 10:56:46 +00:00
def analyse_entry(self, entry, activity):
params = activity.params
2018-06-15 07:46:15 +00:00
self.log.debug('Analysing with the example.')
self.log.debug('The answer to this response is: %s.' % params['parameter'])
2018-06-14 17:38:08 +00:00
resp = Response()
entry['example:reversed'] = entry.text[::-1]
entry['example:the_answer'] = params['parameter']
yield entry
test_cases = [{
'input': 'hello',
'expected': {
'example:reversed': 'olleh'
}
}]