mirror of
https://github.com/gsi-upm/senpy
synced 2025-08-24 02:22:20 +00:00
Merged into monorepo
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
from senpy.plugins import SentimentPlugin
|
||||
from senpy.models import Response, Entry
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class ExamplePlugin(SentimentPlugin):
|
||||
|
||||
def analyse(self, *args, **kwargs):
|
||||
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
|
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "ExamplePlugin",
|
||||
"module": "example",
|
||||
"description": "I am just an example",
|
||||
"author": "@balkian",
|
||||
"version": "0.1",
|
||||
"extra_params": {
|
||||
"parameter": {
|
||||
"@id": "parameter",
|
||||
"aliases": ["parameter", "param"],
|
||||
"required": true,
|
||||
"default": 42
|
||||
}
|
||||
},
|
||||
"requirements": ["noop"],
|
||||
"custom_attribute": "42"
|
||||
}
|
37
example-plugin/example_plugin.py
Normal file
37
example-plugin/example_plugin.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from senpy.plugins import Analysis
|
||||
from senpy.models import Response, Entry
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class ExamplePlugin(Analysis):
|
||||
'''A *VERY* simple plugin that exemplifies the development of Senpy Plugins'''
|
||||
name = "example-plugin"
|
||||
author = "@balkian"
|
||||
version = "0.1"
|
||||
extra_params = {
|
||||
"parameter": {
|
||||
"@id": "parameter",
|
||||
"aliases": ["parameter", "param"],
|
||||
"required": True,
|
||||
"default": 42
|
||||
}
|
||||
}
|
||||
custom_attribute = "42"
|
||||
|
||||
def analyse_entry(self, entry, params):
|
||||
logger.debug('Analysing with the example.')
|
||||
logger.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'
|
||||
}
|
||||
}]
|
@@ -1,23 +0,0 @@
|
||||
import unittest
|
||||
from flask import Flask
|
||||
import os
|
||||
|
||||
from senpy.extensions import Senpy
|
||||
|
||||
class emoTextWAFTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.app = Flask("Example")
|
||||
self.dir = os.path.join(os.path.dirname(__file__))
|
||||
self.senpy = Senpy(plugin_folder=self.dir, default_plugins=False)
|
||||
self.senpy.init_app(self.app)
|
||||
|
||||
def tearDown(self):
|
||||
self.senpy.deactivate_plugin("ExamplePlugin", sync=True)
|
||||
|
||||
def test_analyse(self):
|
||||
assert len(self.senpy.plugins.keys()) == 1
|
||||
assert True
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in New Issue
Block a user