Improve docs. (Badges missing)

pull/39/merge
militarpancho 7 years ago committed by J. Fernando Sánchez
parent 2ea01aef42
commit 3e0f55dcff

@ -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
}

@ -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>`__): 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>`__):

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

@ -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

@ -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.

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

@ -1,4 +1,4 @@
Schema Examples
------ ------
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>`.
@ -17,6 +17,8 @@ Sentiment Analysis
..................... .....................
Description 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 Representation
,,,,,,,,,,,,,, ,,,,,,,,,,,,,,
@ -29,6 +31,7 @@ Suggestion Mining
................. .................
Description 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 Representation
,,,,,,,,,,,,,, ,,,,,,,,,,,,,,
@ -41,6 +44,7 @@ Emotion Analysis
................ ................
Description 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 Representation
,,,,,,,,,,,,,, ,,,,,,,,,,,,,,
@ -53,7 +57,7 @@ Named Entity Recognition
........................ ........................
Description 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 Representation
,,,,,,,,,,,,,, ,,,,,,,,,,,,,,

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

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

@ -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_.

@ -5,69 +5,11 @@ First of all, you need to install the package.
See :doc:`installation` for installation instructions. See :doc:`installation` for installation instructions.
Once installed, the `senpy` command should be available. 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. SenpyClientUse
server
clidemo
commandline
.. 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
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`

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

Loading…
Cancel
Save