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

Improve docs. (Badges missing)

This commit is contained in:
militarpancho 2017-04-07 14:19:08 +02:00 committed by J. Fernando Sánchez
parent 2ea01aef42
commit 3e0f55dcff
12 changed files with 317 additions and 73 deletions

255
docs/SenpyClientUse.ipynb Normal file
View File

@ -0,0 +1,255 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Client"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Demo Endpoint\n",
"-------------"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Import Client and send a request"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from senpy.client import Client\n",
"\n",
"c = Client('http://latest.senpy.cluster.gsi.dit.upm.es/api')\n",
"r = c.analyse('I like Pizza', algorithm='sentiment140')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Print response"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I like Pizza -> marl:Positive\n"
]
}
],
"source": [
"for entry in r.entries:\n",
" print('{} -> {}'.format(entry['text'], entry['sentiments'][0]['marl:hasPolarity']))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Obtain a list of available plugins "
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"emoRand\n",
"rand\n",
"sentiment140\n"
]
}
],
"source": [
"for plugin in c.request('/plugins')['plugins']:\n",
" print(plugin['name'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Local Endpoint\n",
"--------------"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Run a docker container with Senpy image and default plugins"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a0157cd98057072388bfebeed78a830da7cf0a796f4f1a3fd9188f9f2e5fe562\r\n"
]
}
],
"source": [
"!docker run -ti --name 'SenpyEndpoint' -d -p 5000:5000 gsiupm/senpy:0.8.6 --host 0.0.0.0 --default-plugins"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Import client and send a request to localhost"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"c_local = Client('http://127.0.0.1:5000/api')\n",
"r = c_local.analyse('Hello world', algorithm='sentiment140')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Print response"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello world -> marl:Neutral\n"
]
}
],
"source": [
"for entry in r.entries:\n",
" print('{} -> {}'.format(entry['text'], entry['sentiments'][0]['marl:hasPolarity']))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Obtain a list of available plugins deployed locally"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rand\n",
"sentiment140\n",
"emoRand\n"
]
}
],
"source": [
"for plugin in c_local.request('/plugins')['plugins']:\n",
" print(plugin['name'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Stop the docker container"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SenpyEndpoint\n",
"SenpyEndpoint\n"
]
}
],
"source": [
"!docker stop SenpyEndpoint\n",
"!docker rm SenpyEndpoint"
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 1
}

View File

@ -1,4 +1,4 @@
Research
About
--------
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>`__):

View File

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

10
docs/clidemo.rst Normal file
View File

@ -0,0 +1,10 @@
Client demo
===========
This video shows how to use senpy through command-line tool.
.. image:: https://asciinema.org/a/9uwef1ghkjk062cw2t4mhzpyk.png
:width: 100%
:target: https://asciinema.org/a/9uwef1ghkjk062cw2t4mhzpyk
:alt: CLI demo

24
docs/commandline.rst Normal file
View File

@ -0,0 +1,24 @@
Command line
============
In case you want to load modules, which are located in different folders under the root folder, use the next option.
.. code:: bash
senpy -f .
The default port used by senpy is 5000, but you can change it using the `--port` flag.
.. code:: bash
senpy --port 8080
Also, the host can be changed where senpy is deployed. The default value is `127.0.0.1`.
.. code:: bash
senpy --host 0.0.0.0
For more options, see the `--help` page.
Alternatively, you can use the modules included in senpy to build your own application.

View File

@ -37,7 +37,8 @@ extensions = [
'sphinx.ext.todo',
'sphinxcontrib.httpdomain',
'sphinx.ext.coverage',
'sphinx.ext.autosectionlabel'
'sphinx.ext.autosectionlabel',
'nbsphinx'
]
# Add any paths that contain templates here, relative to this directory.

View File

@ -1,4 +1,4 @@
Schema
Examples
------
All the examples in this page use the :download:`the main schema <_static/schemas/definitions.json>`.
@ -17,6 +17,8 @@ Sentiment Analysis
.....................
Description
,,,,,,,,,,,
This annotation corresponds to the sentiment analysis of an input. The example shows the sentiment represented according to Marl format.
The sentiments detected are contained in the Sentiments array with their related part of the text.
Representation
,,,,,,,,,,,,,,
@ -29,6 +31,7 @@ Suggestion Mining
.................
Description
,,,,,,,,,,,
The suggestions schema represented below shows the suggestions detected in the text. Within it, we can find the NIF fields highlighted that corresponds to the text of the detected suggestion.
Representation
,,,,,,,,,,,,,,
@ -41,6 +44,7 @@ Emotion Analysis
................
Description
,,,,,,,,,,,
This annotation represents the emotion analysis of an input to Senpy. The emotions are contained in the emotions section with the text that refers to following Onyx format and the emotion model defined beforehand.
Representation
,,,,,,,,,,,,,,
@ -53,7 +57,7 @@ Named Entity Recognition
........................
Description
,,,,,,,,,,,
The Named Entity Recognition is represented as follows. In this particular case, it can be seen within the entities array the entities recognised. For the example input, Microsoft and Windows Phone are the ones detected.
Representation
,,,,,,,,,,,,,,

View File

@ -20,9 +20,9 @@ Senpy provides:
senpy
installation
demo
usage
apischema
plugins
conversion
demo
research.rst
about

View File

@ -1 +1,2 @@
sphinxcontrib-httpdomain>=1.4
nbsphinx

8
docs/server.rst Normal file
View File

@ -0,0 +1,8 @@
Senpy server
============
Once the server is launched, there is a basic endpoint in the server, which provides a playground to use the plugins that have been loaded.
In case you want to know the different endpoints of the server, there is more information available in the NIF API section_.

View File

@ -5,69 +5,11 @@ First of all, you need to install the package.
See :doc:`installation` for installation instructions.
Once installed, the `senpy` command should be available.
Useful command-line options
===========================
.. toctree::
In case you want to load modules, which are located in different folders under the root folder, use the next option.
.. code:: bash
senpy -f .
The default port used by senpy is 5000, but you can change it using the `--port` flag.
.. code:: bash
senpy --port 8080
Also, the host can be changed where senpy is deployed. The default value is `127.0.0.1`.
.. code:: bash
senpy --host 0.0.0.0
For more options, see the `--help` page.
Alternatively, you can use the modules included in senpy to build your own application.
Senpy server
============
Once the server is launched, there is a basic endpoint in the server, which provides a playground to use the plugins that have been loaded.
In case you want to know the different endpoints of the server, there is more information available in the NIF API section_.
CLI demo
========
This video shows how to use senpy through command-line tool.
.. image:: https://asciinema.org/a/9uwef1ghkjk062cw2t4mhzpyk.png
:width: 100%
:target: https://asciinema.org/a/9uwef1ghkjk062cw2t4mhzpyk
:alt: CLI demo
SenpyClientUse
server
clidemo
commandline
Built-in client
===============
This example shows how to make a request to the default plugin:
.. code:: python
from senpy.client import Client
c = Client('http://127.0.0.1:5000/api/')
r = c.analyse('hello world')
for entry in r.entries:
print('{} -> {}'.format(entry.text, entry.emotions))
.. _section: http://senpy.readthedocs.org/en/latest/api.html
Conversion
==========
See :doc:`conversion`

View File

@ -22,7 +22,6 @@ class Client(object):
response = requests.request(method=method, url=url, params=params)
try:
resp = models.from_dict(response.json())
resp.validate(resp)
except Exception as ex:
logger.error(('There seems to be a problem with the response:\n'
'\tURL: {url}\n'