Commit a20252e4 authored by J. Fernando Sánchez's avatar J. Fernando Sánchez
Browse files

Update docs + notebooks

parent 9758a297
...@@ -21,16 +21,16 @@ before_script: ...@@ -21,16 +21,16 @@ before_script:
except: except:
- tags # Avoid unnecessary double testing - tags # Avoid unnecessary double testing
test-3.5: test-3.6:
<<: *test_definition <<: *test_definition
variables: variables:
PYTHON_VERSION: "3.5" PYTHON_VERSION: "3.6"
test-2.7: test-3.7:
<<: *test_definition <<: *test_definition
allow_failure: true allow_failure: true
variables: variables:
PYTHON_VERSION: "2.7" PYTHON_VERSION: "3.7"
push: push:
stage: push stage: push
...@@ -101,4 +101,3 @@ cleanup_py: ...@@ -101,4 +101,3 @@ cleanup_py:
when: always # this is important; run even if preceding stages failed. when: always # this is important; run even if preceding stages failed.
script: script:
- rm -vf ~/.pypirc # we don't want to leave these around, but GitLab may clean up anyway. - rm -vf ~/.pypirc # we don't want to leave these around, but GitLab may clean up anyway.
- docker logout
...@@ -6,7 +6,10 @@ services: ...@@ -6,7 +6,10 @@ services:
language: python language: python
env: env:
- PYV=2.7 - PYV=3.3
- PYV=3.4
- PYV=3.5 - PYV=3.5
- PYV=3.6
- PYV=3.7
# run nosetests - Tests # run nosetests - Tests
script: make test-$PYV script: make test-$PYV
This diff is collapsed.
%% Cell type:markdown id: tags:
# Senpy in 1 minute
This mini-tutorial is the first in the series of senpy tutorials. It only shows how to annotate with a service.
In this first tutorial, we will use the [demo server](http://senpy.gsi.upm.es), which runs some open source plugins for sentiment and emotion analysis.
%% Cell type:markdown id: tags:
Annotating with senpy is as simple as issuing an HTTP request to the API using your favourite tool.
This is just an example using curl:
%% Cell type:code id: tags:
``` python
!curl "http://senpy.gsi.upm.es/api/sentiment140" --data-urlencode "input=Senpy is awesome"
```
%%%% Output: stream
{
"@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD8j",
"@type": "Results",
"entries": [
{
"@id": "prefix:",
"@type": "Entry",
"marl:hasOpinion": [
{
"@type": "Sentiment",
"marl:hasPolarity": "marl:Positive",
"prov:wasGeneratedBy": "prefix:Analysis_1554389334.6431913"
}
],
"nif:isString": "Senpy is awesome",
"onyx:hasEmotionSet": []
}
]
}
%% Cell type:markdown id: tags:
Congratulations, you've used your first senpy service!
%% Cell type:markdown id: tags:
Here is the equivalent using the `requests` library:
%% Cell type:code id: tags:
``` python
import requests
res = requests.get('http://senpy.gsi.upm.es/api/sentiment140',
params={"input": "Senpy is awesome",})
print(res.text)
```
%%%% Output: stream
{
"@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lIw%3D%3D",
"@type": "Results",
"entries": [
{
"@id": "prefix:",
"@type": "Entry",
"marl:hasOpinion": [
{
"@type": "Sentiment",
"marl:hasPolarity": "marl:Positive",
"prov:wasGeneratedBy": "prefix:Analysis_1554389335.9803226"
}
],
"nif:isString": "Senpy is awesome",
"onyx:hasEmotionSet": []
}
]
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -6,4 +6,5 @@ Advanced usage ...@@ -6,4 +6,5 @@ Advanced usage
server-cli server-cli
conversion conversion
commandline commandline
\ No newline at end of file development
...@@ -38,6 +38,8 @@ extensions = [ ...@@ -38,6 +38,8 @@ extensions = [
'sphinxcontrib.httpdomain', 'sphinxcontrib.httpdomain',
'sphinx.ext.coverage', 'sphinx.ext.coverage',
'sphinx.ext.autosectionlabel', 'sphinx.ext.autosectionlabel',
'nbsphinx',
'sphinx.ext.mathjax',
] ]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
...@@ -54,7 +56,7 @@ master_doc = 'index' ...@@ -54,7 +56,7 @@ 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'2019, J. Fernando Sánchez'
description = u'A framework for sentiment and emotion analysis services' 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
...@@ -79,7 +81,7 @@ language = None ...@@ -79,7 +81,7 @@ language = None
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
exclude_patterns = ['_build'] exclude_patterns = ['_build', '**.ipynb_checkpoints']
# The reST default role (used for this markup: `text`) to use for all # The reST default role (used for this markup: `text`) to use for all
# documents. # documents.
...@@ -286,3 +288,13 @@ texinfo_documents = [ ...@@ -286,3 +288,13 @@ texinfo_documents = [
# If true, do not generate a @detailmenu in the "Top" node's menu. # If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False #texinfo_no_detailmenu = False
nbsphinx_prolog = """
.. note:: This page has been auto-generated from a Jupyter notebook using nbsphinx_.
The original source is available at: https://github.com/gsi-upm/senpy/tree/master/docs//{{ env.doc2path(env.docname, base=None) }}
.. _nbsphinx: https://nbsphinx.readthedocs.io/
----
"""
...@@ -4,11 +4,10 @@ Demo ...@@ -4,11 +4,10 @@ Demo
There is a demo available on http://senpy.gsi.upm.es/, where you can test a live instance of Senpy, with several open source plugins. There is a demo available on http://senpy.gsi.upm.es/, where you can test a live instance of Senpy, with several open source plugins.
You can use the playground (a web interface) or make HTTP requests to the service API. You can use the playground (a web interface) or make HTTP requests to the service API.
.. image:: senpy-playground.png .. image:: playground-0.20.png
:height: 400px :target: http://senpy.gsi.upm.es
:width: 800px :width: 800px
:scale: 100 %
:align: center :align: center
The source code and description of the plugins used in the demo are available here: https://lab.gsi.upm.es/senpy/senpy-plugins-community/. The source code and description of the plugins used in the demo are available here: https://github.com/gsi-upm/senpy-plugins-community/.
...@@ -25,10 +25,9 @@ To get familiar with the concepts behind Senpy, and what it can offer for servic ...@@ -25,10 +25,9 @@ To get familiar with the concepts behind Senpy, and what it can offer for servic
:maxdepth: 2 :maxdepth: 2
senpy senpy
Quickstart demo
Quickstart.ipynb
installation installation
development
apischema apischema
advanced advanced
demo
publications publications
...@@ -22,7 +22,7 @@ Hence, two parts are necessary: 1) the code that will process the entry, and 2) ...@@ -22,7 +22,7 @@ Hence, two parts are necessary: 1) the code that will process the entry, and 2)
In practice, this is what a plugin looks like, tests included: In practice, this is what a plugin looks like, tests included:
.. literalinclude:: ../senpy/plugins/example/rand_plugin.py .. literalinclude:: ../example-plugins/rand_plugin.py
:emphasize-lines: 5-11 :emphasize-lines: 5-11
:language: python :language: python
...@@ -76,8 +76,9 @@ Most plugins will need access to files (dictionaries, lexicons, etc.). ...@@ -76,8 +76,9 @@ Most plugins will need access to files (dictionaries, lexicons, etc.).
These files are usually heavy or under a license that does not allow redistribution. These files are usually heavy or under a license that does not allow redistribution.
For this reason, senpy has a `data_folder` that is separated from the source files. For this reason, senpy has a `data_folder` that is separated from the source files.
The location of this folder is controlled programmatically or by setting the `SENPY_DATA` environment variable. The location of this folder is controlled programmatically or by setting the `SENPY_DATA` environment variable.
You can use the `self.path(filepath)` function to get the path of a given `filepath` within the data folder.
Plugins have a convenience function `self.open` which will automatically prepend the data folder to relative paths: Plugins have a convenience function `self.open` which will automatically look for the file if it exists, or open a new one if it doesn't:
.. code:: python .. code:: python
...@@ -132,7 +133,7 @@ And you can run it with: ...@@ -132,7 +133,7 @@ And you can run it with:
docker run -p 5000:5000 gsiupm/exampleplugin docker run -p 5000:5000 gsiupm/exampleplugin
If the plugin uses non-source files (:ref:`loading data and files`), the recommended way is to use `SENPY_DATA` folder. If the plugin uses non-source files (:ref:`How should I load external data and files`), the recommended way is to use `SENPY_DATA` folder.
Data can then be mounted in the container or added to the image. Data can then be mounted in the container or added to the image.
The former is recommended for open source plugins with licensed resources, whereas the latter is the most convenient and can be used for private images. The former is recommended for open source plugins with licensed resources, whereas the latter is the most convenient and can be used for private images.
......
sphinxcontrib-httpdomain>=1.4 sphinxcontrib-httpdomain>=1.4
ipykernel
nbsphinx nbsphinx
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment