From 69ac95bb08c4c8523b051bf9ebc23d38e82d57a9 Mon Sep 17 00:00:00 2001 From: militarpancho Date: Fri, 2 Jun 2017 17:39:16 +0200 Subject: [PATCH 1/2] Added example plugin in docs. #34 --- docs/plugins.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/plugins.rst b/docs/plugins.rst index decf558..bb56c65 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -98,7 +98,7 @@ The value may be any valid JSON-LD dictionary. For simplicity, senpy includes a series of models by default in the ``senpy.models`` module. -Example plugin +Example pluginhttps://lab.cluster.gsi.dit.upm.es/senpy/plugin-prueba ============== In this section, we will implement a basic sentiment analysis plugin. @@ -113,7 +113,7 @@ The definition file would look like this: module: helloworld version: 0.0 threshold: 10 - + description: Hello World Now, in a file named ``helloworld.py``: @@ -122,11 +122,11 @@ Now, in a file named ``helloworld.py``: #!/bin/env python #helloworld.py - from senpy.plugins import SenpyPlugin + from senpy.plugins import AnalysisPlugin from senpy.models import Sentiment - class HelloWorld(SenpyPlugin): + class HelloWorld(AnalysisPlugin): def analyse_entry(entry, params): '''Basically do nothing with each entry''' @@ -139,6 +139,8 @@ Now, in a file named ``helloworld.py``: entry.sentiments.append(sentiment) yield entry +A repository with the code of an example plugin adding extra data is available `here `__ + F.A.Q. ====== @@ -166,7 +168,7 @@ Training a classifier can be time time consuming. To avoid running the training from senpy.plugins import ShelfMixin, SenpyPlugin - class MyPlugin(ShelfMixin, SenpyPlugin): + class MyPlugin(ShelfMixin, AnalysisPlugin): def train(self): ''' Code to train the classifier ''' @@ -277,7 +279,6 @@ Additionally, with the ``--pdb`` option you will be dropped into a pdb post mort senpy --pdb - Where can I find more code examples? ???????????????????????????????????? From 5bab9a6a02fe685637c23dee901eb474ea24feae Mon Sep 17 00:00:00 2001 From: militarpancho Date: Fri, 2 Jun 2017 17:43:18 +0200 Subject: [PATCH 2/2] #34. Fixed some errors from plugins examples --- docs/plugins.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/plugins.rst b/docs/plugins.rst index bb56c65..770f6cc 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -98,7 +98,7 @@ The value may be any valid JSON-LD dictionary. For simplicity, senpy includes a series of models by default in the ``senpy.models`` module. -Example pluginhttps://lab.cluster.gsi.dit.upm.es/senpy/plugin-prueba +Example plugin ============== In this section, we will implement a basic sentiment analysis plugin. @@ -166,7 +166,7 @@ Training a classifier can be time time consuming. To avoid running the training .. code:: python - from senpy.plugins import ShelfMixin, SenpyPlugin + from senpy.plugins import ShelfMixin, AnalysisPlugin class MyPlugin(ShelfMixin, AnalysisPlugin): def train(self):