mirror of
https://github.com/gsi-upm/senpy
synced 2025-08-23 18:12:20 +00:00
Improved plugins, better tests, gevent
Moved from Yapsy again (it is not flexible enough), now we use a custom solution. The activation and deactivation of plugins is asynchronous, so that plugins that take a long time don't interfere with the rest.
This commit is contained in:
@@ -6,19 +6,6 @@ from senpy.models import Response, Opinion, Entry
|
||||
|
||||
|
||||
class Sentiment140Plugin(SentimentPlugin):
|
||||
EXTRA_PARAMS = {
|
||||
"language": {"aliases": ["language", "l"],
|
||||
"required": False,
|
||||
"options": ["es", "en", "auto"],
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(Sentiment140Plugin, self).__init__(name="sentiment140",
|
||||
version="2.0",
|
||||
extraparams=self.EXTRA_PARAMS,
|
||||
**kwargs)
|
||||
|
||||
def analyse(self, **params):
|
||||
lang = params.get("language", "auto")
|
||||
res = requests.post("http://www.sentiment140.com/api/bulkClassifyJson",
|
||||
@@ -45,5 +32,3 @@ class Sentiment140Plugin(SentimentPlugin):
|
||||
entry.language = lang
|
||||
response.entries.append(entry)
|
||||
return response
|
||||
|
||||
plugin = Sentiment140Plugin()
|
15
plugins/sentiment140/sentiment140.senpy
Normal file
15
plugins/sentiment140/sentiment140.senpy
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "sentiment140",
|
||||
"module": "sentiment140",
|
||||
"description": "What my plugin broadly does",
|
||||
"author": "@balkian",
|
||||
"version": "0.1",
|
||||
"extra_params": {
|
||||
"language": {
|
||||
"aliases": ["language", "l"],
|
||||
"required": false,
|
||||
"options": ["es", "en", "auto"]
|
||||
}
|
||||
},
|
||||
"requirements": {}
|
||||
}
|
Reference in New Issue
Block a user