mirror of
https://github.com/gsi-upm/senpy
synced 2025-08-24 10:32:20 +00:00
Add 'community-plugins/' from commit '4c73797246c6aff8d055abfef73d3f0d34b933a8'
git-subtree-dir: community-plugins git-subtree-mainline:7f712952be
git-subtree-split:4c73797246
This commit is contained in:
36
community-plugins/example-plugin/example_plugin.py
Normal file
36
community-plugins/example-plugin/example_plugin.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from senpy.plugins import AnalysisPlugin
|
||||
from senpy.models import Response, Entry
|
||||
|
||||
|
||||
class ExamplePlugin(AnalysisPlugin):
|
||||
'''A *VERY* simple plugin that exemplifies the development of Senpy Plugins'''
|
||||
name = "example-plugin"
|
||||
author = "@balkian"
|
||||
version = "0.1"
|
||||
extra_params = {
|
||||
"parameter": {
|
||||
"@id": "parameter",
|
||||
"description": "this parameter does nothing, it is only an example",
|
||||
"aliases": ["parameter", "param"],
|
||||
"required": True,
|
||||
"default": 42
|
||||
}
|
||||
}
|
||||
custom_attribute = "42"
|
||||
|
||||
def analyse_entry(self, entry, activity):
|
||||
params = activity.params
|
||||
self.log.debug('Analysing with the example.')
|
||||
self.log.debug('The answer to this response is: %s.' % params['parameter'])
|
||||
resp = Response()
|
||||
entry['example:reversed'] = entry.text[::-1]
|
||||
entry['example:the_answer'] = params['parameter']
|
||||
|
||||
yield entry
|
||||
|
||||
test_cases = [{
|
||||
'input': 'hello',
|
||||
'expected': {
|
||||
'example:reversed': 'olleh'
|
||||
}
|
||||
}]
|
Reference in New Issue
Block a user