1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-22 16:12:29 +00:00

Merge branch '20-improve-docs' into 0.8.x

This commit is contained in:
J. Fernando Sánchez 2017-04-04 11:26:33 +02:00
commit ad1092690b
14 changed files with 351 additions and 266 deletions

BIN
docs/_static/header.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

View File

@ -1,5 +1,5 @@
NIF API NIF API
======= -------
.. http:get:: /api .. http:get:: /api
Basic endpoint for sentiment/emotion analysis. Basic endpoint for sentiment/emotion analysis.
@ -22,38 +22,32 @@ NIF API
Content-Type: text/javascript Content-Type: text/javascript
{ {
"@context": [ "@context":"http://127.0.0.1/api/contexts/Results.jsonld",
"http://127.0.0.1/static/context.jsonld", "@id":"_:Results_11241245.22",
], "@type":"results"
"analysis": [ "analysis": [
{ "plugins/sentiment-140_0.1"
"@id": "SentimentAnalysisExample", ],
"@type": "marl:SentimentAnalysis", "entries": [
"dc:language": "en", {
"marl:maxPolarityValue": 10.0, "@id": "_:Entry_11241245.22"
"marl:minPolarityValue": 0.0 "@type":"entry",
} "emotions": [],
], "entities": [],
"domain": "wndomains:electronics", "sentiments": [
"entries": [ {
{ "@id": "Sentiment0",
"opinions": [ "@type": "sentiment",
{ "marl:hasPolarity": "marl:Negative",
"prov:generatedBy": "SentimentAnalysisExample", "marl:polarityValue": 0,
"marl:polarityValue": 7.8, "prefix": ""
"marl:hasPolarity": "marl:Positive", }
"marl:describesObject": "http://www.gsi.dit.upm.es", ],
} "suggestions": [],
], "text": "This text makes me sad.\nwhilst this text makes me happy and surprised at the same time.\nI cannot believe it!",
"nif:isString": "I love GSI", "topics": []
"strings": [ }
{ ]
"nif:anchorOf": "GSI",
"nif:taIdentRef": "http://www.gsi.dit.upm.es"
}
]
}
]
} }
:query i input: No default. Depends on informat and intype :query i input: No default. Depends on informat and intype
@ -92,58 +86,59 @@ NIF API
.. sourcecode:: http .. sourcecode:: http
{ {
"@context": { "@id": "plugins/sentiment-140_0.1",
... "@type": "sentimentPlugin",
}, "author": "@balkian",
"@type": "plugins", "description": "Sentiment classifier using rule-based classification for English and Spanish. This plugin uses sentiment140 data to perform classification. For more information: http://help.sentiment140.com/for-students/",
"plugins": [ "extra_params": {
{ "language": {
"name": "sentiment140", "@id": "lang_sentiment140",
"is_activated": true, "aliases": [
"version": "0.1", "language",
"extra_params": { "l"
"@id": "extra_params_sentiment140_0.1", ],
"language": { "options": [
"required": false, "es",
"@id": "lang_sentiment140", "en",
"options": [ "auto"
"es", ],
"en", "required": false
"auto" }
], },
"aliases": [ "is_activated": true,
"language", "maxPolarityValue": 1.0,
"l" "minPolarityValue": 0.0,
] "module": "sentiment-140",
} "name": "sentiment-140",
}, "requirements": {},
"@id": "sentiment140_0.1" "version": "0.1"
}, { },
"name": "rand", {
"is_activated": true, "@id": "plugins/ExamplePlugin_0.1",
"version": "0.1", "@type": "sentimentPlugin",
"extra_params": { "author": "@balkian",
"@id": "extra_params_rand_0.1", "custom_attribute": "42",
"language": { "description": "I am just an example",
"required": false, "extra_params": {
"@id": "lang_rand", "parameter": {
"options": [ "@id": "parameter",
"es", "aliases": [
"en", "parameter",
"auto" "param"
], ],
"aliases": [ "default": 42,
"language", "required": true
"l" }
] },
} "is_activated": true,
}, "maxPolarityValue": 1.0,
"@id": "rand_0.1" "minPolarityValue": 0.0,
} "module": "example",
] "name": "ExamplePlugin",
} "requirements": "noop",
"version": "0.1"
}
.. http:get:: /api/plugins/<pluginname> .. http:get:: /api/plugins/<pluginname>
@ -162,30 +157,60 @@ NIF API
.. sourcecode:: http .. sourcecode:: http
{ {
"@id": "rand_0.1", "@context": "http://127.0.0.1/api/contexts/ExamplePlugin.jsonld",
"@type": "sentimentPlugin", "@id": "plugins/ExamplePlugin_0.1",
"extra_params": { "@type": "sentimentPlugin",
"@id": "extra_params_rand_0.1", "author": "@balkian",
"language": { "custom_attribute": "42",
"@id": "lang_rand", "description": "I am just an example",
"aliases": [ "extra_params": {
"language", "parameter": {
"l" "@id": "parameter",
], "aliases": [
"options": [ "parameter",
"es", "param"
"en", ],
"auto" "default": 42,
], "required": true
"required": false }
} },
}, "is_activated": true,
"is_activated": true, "maxPolarityValue": 1.0,
"name": "rand", "minPolarityValue": 0.0,
"version": "0.1" "module": "example",
"name": "ExamplePlugin",
"requirements": "noop",
"version": "0.1"
} }
.. http:get:: /api/plugins/default .. http:get:: /api/plugins/default
Return the information about the default plugin. Return the information about the default plugin.

7
docs/apischema.rst Normal file
View File

@ -0,0 +1,7 @@
API and Schema
##############
.. toctree::
vocabularies.rst
api.rst
schema.rst

15
docs/architecture.rst Normal file
View File

@ -0,0 +1,15 @@
Architecture
============
The main component of a sentiment analysis service is the algorithm itself. However, for the algorithm to work, it needs to get the appropriate parameters from the user, format the results according to the defined API, interact with the user whn errors occur or more information is needed, etc.
Senpy proposes a modular and dynamic architecture that allows:
* Implementing different algorithms in a extensible way, yet offering a common interface.
* Offering common services that facilitate development, so developers can focus on implementing new and better algorithms.
The framework consists of two main modules: Senpy core, which is the building block of the service, and Senpy plugins, which consist of the analysis algorithm. The next figure depicts a simplified version of the processes involved in an analysis with the Senpy framework.
.. image:: senpy-architecture.png
:width: 100%
:align: center

View File

@ -37,6 +37,7 @@ extensions = [
'sphinx.ext.todo', 'sphinx.ext.todo',
'sphinxcontrib.httpdomain', 'sphinxcontrib.httpdomain',
'sphinx.ext.coverage', 'sphinx.ext.coverage',
'sphinx.ext.autosectionlabel'
] ]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
@ -54,20 +55,21 @@ master_doc = 'index'
# General information about the project. # General information about the project.
project = u'Senpy' project = u'Senpy'
copyright = u'2016, J. Fernando Sánchez' copyright = u'2016, J. Fernando Sánchez'
description = u'A framework for sentiment and emotion analysis services'
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
with open('../senpy/VERSION') as f: # with open('../senpy/VERSION') as f:
version = f.read().strip() # version = f.read().strip()
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = version # release = version
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
#language = None language = None
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
@ -104,14 +106,14 @@ pygments_style = 'sphinx'
#keep_warnings = False #keep_warnings = False
html_theme = 'alabaster'
# -- Options for HTML output ---------------------------------------------- # -- Options for HTML output ----------------------------------------------
if not on_rtd: # only import and set the theme if we're building docs locally # if not on_rtd: # only import and set the theme if we're building docs locally
import sphinx_rtd_theme # import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme' # html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
else: # else:
html_theme = 'default' # html_theme = 'default'
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
@ -119,7 +121,13 @@ else:
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the
# documentation. # documentation.
#html_theme_options = {} html_theme_options = {
'logo': 'header.png',
'github_user': 'gsi-upm',
'github_repo': 'senpy',
'github_banner': True,
}
# Add any paths that contain custom themes here, relative to this directory. # Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = [] #html_theme_path = []
@ -159,7 +167,13 @@ html_static_path = ['_static']
#html_use_smartypants = True #html_use_smartypants = True
# Custom sidebar templates, maps document names to template names. # Custom sidebar templates, maps document names to template names.
#html_sidebars = {} html_sidebars = {
'**': [
'about.html',
'navigation.html',
'searchbox.html',
]
}
# Additional templates that should be rendered to pages, maps page names to # Additional templates that should be rendered to pages, maps page names to
# template names. # template names.

View File

@ -1,7 +1,8 @@
Demo Demo
---- ----
There is a demo available on http://senpy.demos.gsi.dit.upm.es/, where you can a serie of different plugins. You can use them in the playground or make a directly requests to the service. There is a demo available on http://senpy.cluster.gsi.dit.upm.es/, where you can test a serie of different plugins.
You can use the playground (a web interface) or make HTTP requests to the service API.
.. image:: senpy-playground.png .. image:: senpy-playground.png
:height: 400px :height: 400px
@ -12,64 +13,4 @@ There is a demo available on http://senpy.demos.gsi.dit.upm.es/, where you can a
Plugins Demo Plugins Demo
============ ============
The next plugins are available at the demo: The source code and description of the plugins used in the demo is available here: https://lab.cluster.gsi.dit.upm.es/senpy/senpy-plugins-community/.
* emoTextAnew extracts the VAD (valence-arousal-dominance) of a sentence by matching words from the ANEW dictionary.
* emoTextWordnetAffect based on the hierarchy of WordnetAffect to calculate the emotion of the sentence.
* vaderSentiment utilizes the software from vaderSentiment to calculate the sentiment of a sentence.
* sentiText is a software developed during the TASS 2015 competition, it has been adapted for English and Spanish.
emoTextANEW plugin
******************
This plugin is going to used the ANEW lexicon dictionary to calculate de VAD (valence-arousal-dominance) of the sentence and the determinate which emotion is closer to this value.
Each emotion has a centroid, which it has been approximated using the formula described in this article:
http://www.aclweb.org/anthology/W10-0208
The plugin is going to look for the words in the sentence that appear in the ANEW dictionary and calculate the average VAD score for the sentence. Once this score is calculated, it is going to seek the emotion that is closest to this value.
emoTextWAF plugin
*****************
This plugin uses WordNet-Affect (http://wndomains.fbk.eu/wnaffect.html) to calculate the percentage of each emotion. The emotions that are going to be used are: anger, fear, disgust, joy and sadness. It is has been used a emotion mapping enlarge the emotions:
* anger : general-dislike
* fear : negative-fear
* disgust : shame
* joy : gratitude, affective, enthusiasm, love, joy, liking
* sadness : ingrattitude, daze, humlity, compassion, despair, anxiety, sadness
sentiText plugin
****************
This plugin is based in the classifier developed for the TASS 2015 competition. It has been developed for Spanish and English. The different phases that has this plugin when it is activated:
* Train both classifiers (English and Spanish).
* Initialize resources (dictionaries,stopwords,etc.).
* Extract bag of words,lemmas and chars.
Once the plugin is activated, the features that are going to be extracted for the classifiers are:
* Matches with the bag of words extracted from the train corpus.
* Sentiment score of the sentences extracted from the dictionaries (lexicons and emoticons).
* Identify negations and intensifiers in the sentences.
* Complementary features such as exclamation and interrogation marks, eloganted and caps words, hashtags, etc.
The plugin has a preprocessor, which is focues on Twitter corpora, that is going to be used for cleaning the text to simplify the feature extraction.
There is more information avaliable in the next article.
Aspect based Sentiment Analysis of Spanish Tweets, Oscar Araque and Ignacio Corcuera-Platas and Constantino Román-Gómez and Carlos A. Iglesias and J. Fernando Sánchez-Rada. http://gsi.dit.upm.es/es/investigacion/publicaciones?view=publication&task=show&id=37
vaderSentiment plugin
*********************
For developing this plugin, it has been used the module vaderSentiment, which is described in the paper: VADER: A Parsimonious Rule-based Model for Sentiment Analysis of Social Media Text C.J. Hutto and Eric Gilbert Eighth International Conference on Weblogs and Social Media (ICWSM-14). Ann Arbor, MI, June 2014.
If you use this plugin in your research, please cite the above paper
For more information about the functionality, check the official repository
https://github.com/cjhutto/vaderSentiment

View File

@ -1,15 +1,28 @@
Welcome to Senpy's documentation! Welcome to Senpy's documentation!
================================= =================================
Contents: With Senpy, you can easily turn your sentiment or emotion analysis algorithm into a full blown semantic service.
Sharing your sentiment analysis with the world has never been easier.
Senpy provides:
* Parameter validation, error handling
* Formatting: JSON-LD, Turtle/n-triples input and output, or simple text input
* Linked Data. Results are semantically annotated, using a series of well established vocabularies, and sane default URIs.
* A web UI where users can explore your service and test different settings
* A client to interact with any senpy service
* A command line tool
.. toctree:: .. toctree::
:caption: Learn more about senpy
:maxdepth: 2
senpy senpy
installation installation
usage usage
api apischema
schema
plugins plugins
conversion conversion
demo demo
:maxdepth: 2 research.rst

View File

@ -22,6 +22,35 @@ If you want to install senpy globally, use sudo instead of the ``--user`` flag.
Docker Image Docker Image
************ ************
Build the image or use the pre-built one: ``docker run -ti -p 5000:5000 gsiupm/senpy --host 0.0.0.0 --default-plugins``. Build the image or use the pre-built one:
.. code:: bash
docker run -ti -p 5000:5000 gsiupm/senpy --host 0.0.0.0 --default-plugins
To add custom plugins, use a docker volume:
.. code:: bash
docker run -ti -p 5000:5000 -v <PATH OF PLUGINS>:/plugins gsiupm/senpy --host 0.0.0.0 --default-plugins -f /plugins
Alias
.....
If you are using the docker approach regularly, it is advisable to use a script or an alias to simplify your executions:
.. code:: bash
alias senpy='docker run --rm -ti -p 5000:5000 -v $PWD:/senpy-plugins gsiupm/senpy --default-plugins'
Python 2
........
There is a Senpy version for python2 too:
.. code:: bash
docker run -ti -p 5000:5000 gsiupm/senpy:python2.7 --host 0.0.0.0 --default-plugins
To add custom plugins, add a volume and tell senpy where to find the plugins: ``docker run -ti -p 5000:5000 -v <PATH OF PLUGINS>:/plugins gsiupm/senpy --host 0.0.0.0 --default-plugins -f /plugins``

View File

@ -2,27 +2,34 @@ Developing new plugins
---------------------- ----------------------
This document describes how to develop a new analysis plugin. For an example of conversion plugins, see :doc:`conversion`. This document describes how to develop a new analysis plugin. For an example of conversion plugins, see :doc:`conversion`.
Each plugin represents a different analysis process.There are two types of files that are needed by senpy for loading a plugin: A more step-by-step tutorial with slides is available `here <https://lab.cluster.gsi.dit.upm.es/senpy/senpy-tutorial>`__
- Definition file, has the ".senpy" extension. What is a plugin?
- Code file, is a python file. =================
This separation will allow us to deploy plugins that use the same code but employ different parameters. A plugin is a program that, given a text, will add annotations to it.
In practice, a plugin consists of at least two files:
- Definition file: a `.senpy` file that describes the plugin (e.g. what input parameters it accepts, what emotion model it uses).
- Python module: the actual code that will add annotations to each input.
This separation allows us to deploy plugins that use the same code but employ different parameters.
For instance, one could use the same classifier and processing in several plugins, but train with different datasets. For instance, one could use the same classifier and processing in several plugins, but train with different datasets.
This scenario is particularly useful for evaluation purposes. This scenario is particularly useful for evaluation purposes.
The only limitation is that the name of each plugin needs to be unique. The only limitation is that the name of each plugin needs to be unique.
Plugins Definitions Plugin Definition files
=================== =======================
The definition file contains all the attributes of the plugin, and can be written in YAML or JSON. The definition file contains all the attributes of the plugin, and can be written in YAML or JSON.
When the server is launched, it will recursively search for definition files in the plugin folder (the current folder, by default).
The most important attributes are: The most important attributes are:
* **name**: unique name that senpy will use internally to identify the plugin. * **name**: unique name that senpy will use internally to identify the plugin.
* **module**: indicates the module that contains the plugin code, which will be automatically loaded by senpy. * **module**: indicates the module that contains the plugin code, which will be automatically loaded by senpy.
* **version** * **version**
* extra_params: used to specify parameters that the plugin accepts that are not already part of the senpy API. Those parameters may be required, and have aliased names. For instance: * extra_params: to add parameters to the senpy API when this plugin is requested. Those parameters may be required, and have aliased names. For instance:
.. code:: yaml .. code:: yaml
@ -68,10 +75,28 @@ The basic methods in a plugin are:
* __init__ * __init__
* activate: used to load memory-hungry resources * activate: used to load memory-hungry resources
* deactivate: used to free up resources * deactivate: used to free up resources
* analyse_entry: called in every user requests. It takes in the parameters supplied by a user and should yield one or more ``Entry`` objects. * analyse_entry: called in every user requests. It takes two parameters: ``Entry``, the entry object, and ``params``, the parameters supplied by the user. It should yield one or more ``Entry`` objects.
Plugins are loaded asynchronously, so don't worry if the activate method takes too long. The plugin will be marked as activated once it is finished executing the method. Plugins are loaded asynchronously, so don't worry if the activate method takes too long. The plugin will be marked as activated once it is finished executing the method.
Entries
=======
Entries are objects that can be annotated.
By default, entries are `NIF contexts <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core/nif-core.html>`_ represented in JSON-LD format.
Annotations are added to the object like this:
.. code:: python
entry = Entry()
entry.vocabulary__annotationName = 'myvalue'
entry['vocabulary:annotationName'] = 'myvalue'
entry['annotationNameURI'] = 'myvalue'
Where vocabulary is one of the prefixes defined in the default senpy context, and annotationURI is a full URI.
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 plugin
============== ==============
@ -117,6 +142,13 @@ Now, in a file named ``helloworld.py``:
F.A.Q. F.A.Q.
====== ======
What annotations can I use?
???????????????????????????
You can add almost any annotation to an entry.
The most common use cases are covered in the :doc:`schema`.
Why does the analyse function yield instead of return? Why does the analyse function yield instead of return?
?????????????????????????????????????????????????????? ??????????????????????????????????????????????????????

11
docs/research.rst Normal file
View File

@ -0,0 +1,11 @@
Research
--------
If you use Senpy in your research, please cite `Senpy: A Pragmatic Linked Sentiment Analysis Framework <http://gsi.dit.upm.es/index.php/es/investigacion/publicaciones?view=publication&task=show&id=417>`__ (`BibTex <http://gsi.dit.upm.es/index.php/es/investigacion/publicaciones?controller=publications&task=export&format=bibtex&id=417>`__):
.. code-block:: text
Sánchez-Rada, J. F., Iglesias, C. A., Corcuera, I., & Araque, Ó. (2016, October).
Senpy: A Pragmatic Linked Sentiment Analysis Framework.
In Data Science and Advanced Analytics (DSAA),
2016 IEEE International Conference on (pp. 735-742). IEEE.

View File

@ -1,74 +1,74 @@
Schema Examples Schema
=============== ------
All the examples in this page use the :download:`the main schema <_static/schemas/definitions.json>`. All the examples in this page use the :download:`the main schema <_static/schemas/definitions.json>`.
Simple NIF annotation Simple NIF annotation
--------------------- .....................
Description Description
........... ,,,,,,,,,,,
This example covers the basic example in the NIF documentation: `<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core/nif-core.html>`_. This example covers the basic example in the NIF documentation: `<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core/nif-core.html>`_.
Representation Representation
.............. ,,,,,,,,,,,,,,
.. literalinclude:: examples/example-basic.json .. literalinclude:: examples/results/example-basic.json
:language: json-ld :language: json-ld
Sentiment Analysis Sentiment Analysis
--------------------- .....................
Description Description
........... ,,,,,,,,,,,
Representation Representation
.............. ,,,,,,,,,,,,,,
.. literalinclude:: examples/example-sentiment.json .. literalinclude:: examples/results/example-sentiment.json
:emphasize-lines: 5-10,25-33 :emphasize-lines: 5-10,25-33
:language: json-ld :language: json-ld
Suggestion Mining Suggestion Mining
----------------- .................
Description Description
........... ,,,,,,,,,,,
Representation Representation
.............. ,,,,,,,,,,,,,,
.. literalinclude:: examples/example-suggestion.json .. literalinclude:: examples/results/example-suggestion.json
:emphasize-lines: 5-8,22-27 :emphasize-lines: 5-8,22-27
:language: json-ld :language: json-ld
Emotion Analysis Emotion Analysis
---------------- ................
Description Description
........... ,,,,,,,,,,,
Representation Representation
.............. ,,,,,,,,,,,,,,
.. literalinclude:: examples/example-emotion.json .. literalinclude:: examples/results/example-emotion.json
:language: json-ld :language: json-ld
:emphasize-lines: 5-8,25-37 :emphasize-lines: 5-8,25-37
Named Entity Recognition Named Entity Recognition
------------------------ ........................
Description Description
........... ,,,,,,,,,,,
Representation Representation
.............. ,,,,,,,,,,,,,,
.. literalinclude:: examples/example-ner.json .. literalinclude:: examples/results/example-ner.json
:emphasize-lines: 5-8,19-34 :emphasize-lines: 5-8,19-34
:language: json-ld :language: json-ld
Complete example Complete example
---------------- ................
Description Description
........... ,,,,,,,,,,,
This example covers all of the above cases, integrating all the annotations in the same document. This example covers all of the above cases, integrating all the annotations in the same document.
Representation Representation
.............. ,,,,,,,,,,,,,,
.. literalinclude:: examples/example-complete.json .. literalinclude:: examples/results/example-complete.json
:language: json-ld :language: json-ld

View File

@ -1,35 +1,32 @@
What is Senpy? What is Senpy?
-------------- --------------
Senpy is an open source reference implementation of a linked data model for sentiment and emotion analysis services based on the vocabularies NIF, Marl and Onyx. Senpy is a framework that turns your sentiment or emotion analysis algorithm into a full blown semantic service.
Senpy takes care of:
The overall goal of the reference implementation Senpy is easing the adoption of the proposed linked data model for sentiment and emotion analysis services, so that services from different providers become interoperable. With this aim, the design of the reference implementation has focused on its extensibility and reusability. * Interfacing with the user: parameter validation, error handling.
* Formatting: JSON-LD, Turtle/n-triples input and output, or simple text input
* Linked Data: senpy results are semantically annotated, using a series of well established vocabularies, and sane default URIs.
* User interface: a web UI where users can explore your service and test different settings
* A client to interact with the service. Currently only available in Python.
A modular approach allows organizations to replace individual components with custom ones developed in-house. Furthermore, organizations can benefit from reusing prepackages modules that provide advanced functionalities, such as algorithms for sentiment and emotion analysis, linked data publication or emotion and sentiment mapping between different providers. Sharing your sentiment analysis with the world has never been easier!
Specifications Senpy for service developers
============== ============================
The model used in Senpy is based on the following specifications: Check out the :doc:`plugins` if you have developed an analysis algorithm (e.g. sentiment analysis) and you want to publish it as a service.
* Marl, a vocabulary designed to annotate and describe subjetive opinions expressed on the web or in information systems. Senpy for end users
* Onyx, which is built one the same principles as Marl to annotate and describe emotions, and provides interoperability with Emotion Markup Language. ===================
* NIF 2.0, which defines a semantic format and APO for improving interoperability among natural language processing services
Architecture All services built using senpy share a common interface.
============ This allows users to use them (almost) interchangeably.
Senpy comes with a :ref:`built-in client`.
The main component of a sentiment analysis service is the algorithm itself. However, for the algorithm to work, it needs to get the appropriate parameters from the user, format the results according to the defined API, interact with the user whn errors occur or more information is needed, etc.
Senpy proposes a modular and dynamic architecture that allows: .. toctree::
:caption: Interested? Check out senpy's:
* Implementing different algorithms in a extensible way, yet offering a common interface. architecture
* Offering common services that facilitate development, so developers can focus on implementing new and better algorithms.
The framework consists of two main modules: Senpy core, which is the building block of the service, and Senpy plugins, which consist of the analysis algorithm. The next figure depicts a simplified version of the processes involved in an analysis with the Senpy framework.
.. image:: senpy-architecture.png
:height: 400px
:width: 800px
:scale: 100 %
:align: center

View File

@ -1,20 +1,9 @@
Usage Usage
----- -----
The easiest and recommended way is to just use the command-line tool to load your plugins and launch the server. First of all, you need to install the package.
See :doc:`installation` for installation instructions.
.. code:: bash Once installed, the `senpy` command should be available.
senpy
Or, alternatively:
.. code:: bash
python -m senpy
This will create a server with any modules found in the current path.
Useful command-line options Useful command-line options
=========================== ===========================
@ -23,19 +12,19 @@ In case you want to load modules, which are located in different folders under t
.. code:: bash .. code:: bash
python -m senpy -f . senpy -f .
The default port used by senpy is 5000, but you can change it using the option `--port`. The default port used by senpy is 5000, but you can change it using the `--port` flag.
.. code:: bash .. code:: bash
python -m senpy --port 8080 senpy --port 8080
Also, the host can be changed where senpy is deployed. The default value is `127.0.0.1`. Also, the host can be changed where senpy is deployed. The default value is `127.0.0.1`.
.. code:: bash .. code:: bash
python -m senpy --host 0.0.0.0 senpy --host 0.0.0.0
For more options, see the `--help` page. For more options, see the `--help` page.
@ -48,15 +37,19 @@ Once the server is launched, there is a basic endpoint in the server, which prov
In case you want to know the different endpoints of the server, there is more information available in the NIF API section_. In case you want to know the different endpoints of the server, there is more information available in the NIF API section_.
CLI CLI demo
=== ========
This video shows how to use senpy through command-line tool. This video shows how to use senpy through command-line tool.
https://asciinema.org/a/9uwef1ghkjk062cw2t4mhzpyk .. image:: https://asciinema.org/a/9uwef1ghkjk062cw2t4mhzpyk.png
:width: 100%
:target: https://asciinema.org/a/9uwef1ghkjk062cw2t4mhzpyk
:alt: CLI demo
Request example in python
========================= Built-in client
===============
This example shows how to make a request to the default plugin: This example shows how to make a request to the default plugin:

8
docs/vocabularies.rst Normal file
View File

@ -0,0 +1,8 @@
Vocabularies and model
======================
The model used in Senpy is based on the following vocabularies:
* Marl, a vocabulary designed to annotate and describe subjetive opinions expressed on the web or in information systems.
* Onyx, which is built one the same principles as Marl to annotate and describe emotions, and provides interoperability with Emotion Markup Language.
* NIF 2.0, which defines a semantic format and APO for improving interoperability among natural language processing services