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

Small tweaks in docs

parent 7aa69e3d
......@@ -6,10 +6,10 @@ services:
language: python
env:
- PYV=3.3
- PYV=3.4
- PYV=3.5
- PYV=3.6
- PYV=3.7
# - PYV=3.3 # Apt fails in this docker image
# run nosetests - Tests
script: make test-$PYV
......@@ -83,7 +83,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
......@@ -168,7 +168,7 @@
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Sentiment&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;marl:hasPolarity&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;marl:Positive&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;prov:wasGeneratedBy&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;prefix:Analysis_1554391718.7649393&quot;</span>\n",
" <span class=\"nt\">&quot;prov:wasGeneratedBy&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;prefix:Analysis_1554396807.629645&quot;</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">],</span>\n",
" <span class=\"nt\">&quot;nif:isString&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Senpy is awesome&quot;</span><span class=\"p\">,</span>\n",
......@@ -191,7 +191,7 @@
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Sentiment\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}marl:hasPolarity\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}marl:Positive\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}prov:wasGeneratedBy\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:Analysis\\PYZus{}1554391718.7649393\\PYZdq{}}\n",
" \\PY{n+nt}{\\PYZdq{}prov:wasGeneratedBy\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:Analysis\\PYZus{}1554396807.629645\\PYZdq{}}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}nif:isString\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Senpy is awesome\\PYZdq{}}\\PY{p}{,}\n",
......@@ -213,7 +213,7 @@
" {\n",
" \"@type\": \"Sentiment\",\n",
" \"marl:hasPolarity\": \"marl:Positive\",\n",
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1554391718.7649393\"\n",
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1554396807.629645\"\n",
" }\n",
" ],\n",
" \"nif:isString\": \"Senpy is awesome\",\n",
......@@ -223,7 +223,7 @@
"}"
]
},
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
......
%% Cell type:markdown id: tags:
# Senpy in 10 minutes
This tutorial assumes you have completed the [1 minute tutorial](Quickstart-1minute.ipynb) and you know how to access the API.
It covers:
* Annotating entiment with a sentiment analysis service
* Annotating emotions
* Interoperability of services
* Using other semantic formats (RDF)
%% Cell type:markdown id: tags:
## Requirements
%% Cell type:markdown id: tags:
Once again, we will use the demo server at http://senpy.gsi.upm.es.
This time, we will use the requests library.
We will use a variable for our endpoint, so you can try this examples on a different senpy instance:
%% Cell type:code id: tags:
``` python
endpoint = 'http://senpy.gsi.upm.es/api'
```
%% Cell type:markdown id: tags:
We will also add a function to get syntax highlighting for the JSON-LD/Turtle results:
%% Cell type:code id: tags:
``` python
try:
from IPython.display import Code
def pretty(txt, language='json-ld'):
return Code(txt, language=language)
except ImportError:
def pretty(txt, **kwargs):
print(txt)
```
%% Cell type:markdown id: tags:
## Sentiment Analysis of Text
%% Cell type:markdown id: tags:
To start, let us analyse the sentiment in the following sentence: *senpy is awesome*.
For now, we will use the [sentiment140](http://www.sentiment140.com/) service, through the sentiment140 plugin.
We will later cover how to use a different service.
%% Cell type:code id: tags:
``` python
import requests
res = requests.get(f'{endpoint}/sentiment140',
params={"input": "Senpy is awesome",})
pretty(res.text)
```
%%%% Output: execute_result
\begin{Verbatim}[commandchars=\\\{\}]
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@context\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lIw\PYZpc{}3D\PYZpc{}3D\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Results\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}entries\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@id\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}prefix:\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Entry\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}marl:hasOpinion\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Sentiment\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}marl:hasPolarity\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}marl:Positive\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}prov:wasGeneratedBy\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}prefix:Analysis\PYZus{}1554391718.7649393\PYZdq{}}
\PY{n+nt}{\PYZdq{}prov:wasGeneratedBy\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}prefix:Analysis\PYZus{}1554396807.629645\PYZdq{}}
\PY{p}{\PYZcb{}}
\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}nif:isString\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Senpy is awesome\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionSet\PYZdq{}}\PY{p}{:} \PY{p}{[}\PY{p}{]}
\PY{p}{\PYZcb{}}
\PY{p}{]}
\PY{p}{\PYZcb{}}
\end{Verbatim}
{
"@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_1554391718.7649393"
"prov:wasGeneratedBy": "prefix:Analysis_1554396807.629645"
}
],
"nif:isString": "Senpy is awesome",
"onyx:hasEmotionSet": []
}
]
}
%% Cell type:markdown id: tags:
Senpy services always return an object of type `senpy:Results`, with a list of entries.
You can think of an entry as a self-contained textual context (`nif:Context` and `senpy:Entry`).
Entries can be as short as a sentence, or as long as a news article.
Each entry has a `nif:isString` property that contains the original text of the entry, and several other properties that are provided by the plugins.
For instance, sentiment annotations are provided through `marl:hasOpinion`.
The annotations are semantic.
We can ask Senpy for the expanded JSON-LD output to reveal the full URIs of each property and entity:
%% Cell type:code id: tags:
``` python
import requests
res = requests.get(f'{endpoint}/sentiment140',
params={"input": "Senpy is awesome",
"expanded": True})
pretty(res.text)
```
%%%% Output: execute_result
\begin{Verbatim}[commandchars=\\\{\}]
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@context\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lJmV4cGFuZGVkPVRydWUj\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{l+s+s2}{\PYZdq{}http://www.gsi.upm.es/onto/senpy/ns\PYZsh{}Results\PYZdq{}}
\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}http://www.w3.org/ns/prov\PYZsh{}used\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@id\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}http://senpy.invalid/\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{l+s+s2}{\PYZdq{}http://www.gsi.upm.es/onto/senpy/ns\PYZsh{}Entry\PYZdq{}}
\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}http://persistence.uni\PYZhy{}leipzig.org/nlp2rdf/ontologies/nif\PYZhy{}core\PYZsh{}isString\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@value\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Senpy is awesome\PYZdq{}}
\PY{p}{\PYZcb{}}
\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}http://www.gsi.dit.upm.es/ontologies/marl/ns\PYZsh{}hasOpinion\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{l+s+s2}{\PYZdq{}http://www.gsi.upm.es/onto/senpy/ns\PYZsh{}Sentiment\PYZdq{}}
\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}http://www.gsi.dit.upm.es/ontologies/marl/ns\PYZsh{}hasPolarity\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@value\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}marl:Positive\PYZdq{}}
\PY{p}{\PYZcb{}}
\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}http://www.w3.org/ns/prov\PYZsh{}wasGeneratedBy\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@id\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}http://senpy.invalid/Analysis\PYZus{}1554389672.269198\PYZdq{}}
\PY{p}{\PYZcb{}}
\PY{p}{]}
\PY{p}{\PYZcb{}}
\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}http://www.gsi.dit.upm.es/ontologies/onyx/ns\PYZsh{}hasEmotionSet\PYZdq{}}\PY{p}{:} \PY{p}{[}\PY{p}{]}
\PY{p}{\PYZcb{}}
\PY{p}{]}
\PY{p}{\PYZcb{}}
\end{Verbatim}
{
"@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lJmV4cGFuZGVkPVRydWUj",
"@type": [
"http://www.gsi.upm.es/onto/senpy/ns#Results"
],
"http://www.w3.org/ns/prov#used": [
{
"@id": "http://senpy.invalid/",
"@type": [
"http://www.gsi.upm.es/onto/senpy/ns#Entry"
],
"http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#isString": [
{
"@value": "Senpy is awesome"
}
],
"http://www.gsi.dit.upm.es/ontologies/marl/ns#hasOpinion": [
{
"@type": [
"http://www.gsi.upm.es/onto/senpy/ns#Sentiment"
],
"http://www.gsi.dit.upm.es/ontologies/marl/ns#hasPolarity": [
{
"@value": "marl:Positive"
}
],
"http://www.w3.org/ns/prov#wasGeneratedBy": [
{
"@id": "http://senpy.invalid/Analysis_1554389672.269198"
}
]
}
],
"http://www.gsi.dit.upm.es/ontologies/onyx/ns#hasEmotionSet": []
}
]
}
%% Cell type:markdown id: tags:
## Service interoperability
%% Cell type:markdown id: tags:
All senpy plugins use the same API, which makes moving from one service to another a breeze.
Let us go back to our simple example, which uses the `sentiment140` service.
%% Cell type:code id: tags:
``` python
import requests
res = requests.get(f'{endpoint}/sentiment140',
params={"input": "Senpy is awesome"})
pretty(res.text)
```
%%%% Output: execute_result
\begin{Verbatim}[commandchars=\\\{\}]
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@context\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lIw\PYZpc{}3D\PYZpc{}3D\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Results\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}entries\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@id\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}prefix:\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Entry\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}marl:hasOpinion\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Sentiment\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}marl:hasPolarity\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}marl:Positive\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}prov:wasGeneratedBy\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}prefix:Analysis\PYZus{}1554389675.2303865\PYZdq{}}
\PY{p}{\PYZcb{}}
\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}nif:isString\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Senpy is awesome\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionSet\PYZdq{}}\PY{p}{:} \PY{p}{[}\PY{p}{]}
\PY{p}{\PYZcb{}}
\PY{p}{]}
\PY{p}{\PYZcb{}}
\end{Verbatim}
{
"@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_1554389675.2303865"
}
],
"nif:isString": "Senpy is awesome",
"onyx:hasEmotionSet": []
}
]
}
%% Cell type:markdown id: tags:
If we wanted to use a different service (e.g. the `sentiment-basic` plugin), we can do it just by changing the URL of the service:
%% Cell type:code id: tags:
``` python
import requests
res = requests.get(f'{endpoint}/sentiment-basic',
params={"input": "Senpy is awesome"})
pretty(res.text)
```
%%%% Output: execute_result
\begin{Verbatim}[commandchars=\\\{\}]
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@context\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudC1iYXNpYz9pbnB1dD1TZW5weStpcythd2Vzb21lIw\PYZpc{}3D\PYZpc{}3D\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Results\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}entries\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@id\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}prefix:\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Entry\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}marl:hasOpinion\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Sentiment\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}marl:hasPolarity\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}marl:Neutral\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}prov:wasGeneratedBy\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}prefix:Analysis\PYZus{}1554389675.9911203\PYZdq{}}
\PY{p}{\PYZcb{}}
\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}nif:isString\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Senpy is awesome\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionSet\PYZdq{}}\PY{p}{:} \PY{p}{[}\PY{p}{]}
\PY{p}{\PYZcb{}}
\PY{p}{]}
\PY{p}{\PYZcb{}}
\end{Verbatim}
{
"@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudC1iYXNpYz9pbnB1dD1TZW5weStpcythd2Vzb21lIw%3D%3D",
"@type": "Results",
"entries": [
{
"@id": "prefix:",
"@type": "Entry",
"marl:hasOpinion": [
{
"@type": "Sentiment",
"marl:hasPolarity": "marl:Neutral",
"prov:wasGeneratedBy": "prefix:Analysis_1554389675.9911203"
}
],
"nif:isString": "Senpy is awesome",
"onyx:hasEmotionSet": []
}
]
}
%% Cell type:markdown id: tags:
As you can see, the structure and annotation schema of the response is the same.
This makes it very easy to compare and migrate to different services.
Service interoperability is not only useful for users.
It is also key for other features such as [automated evaluation](#Evaluation).
This is a compelling reason to adapt existing services to use the Senpy API.
In fact, the `sentiment140` senpy service is proxy to the public [Sentiment 140 service](http://www.sentiment140.com/).
%% Cell type:markdown id: tags:
## Emotion analysis
%% Cell type:markdown id: tags:
Senpy uses the `onyx` vocabulary to represent emotions, which incorporates the notion of `EmotionSet`'s, an emotion that is composed of several emotions.
In a nutshell, an `Entry` is linked to one or more `EmotionSet`, which in turn is made up of one or more `Emotion`.
Let's illustrate it with an example, using the `emotion-depechemood` plugin.
%% Cell type:code id: tags:
``` python
res = requests.get(f'{endpoint}/emotion-depechemood',
params={"input": "Senpy is a wonderful that service"})
pretty(res.text)
```
%%%% Output: execute_result
\begin{Verbatim}[commandchars=\\\{\}]
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@context\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tZGVwZWNoZW1vb2Q\PYZus{}aW5wdXQ9U2VucHkraXMrYSt3b25kZXJmdWwrdGhhdCtzZXJ2aWNlIw\PYZpc{}3D\PYZpc{}3D\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Results\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}entries\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@id\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}prefix:\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Entry\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}marl:hasOpinion\PYZdq{}}\PY{p}{:} \PY{p}{[}\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}nif:isString\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Senpy is a wonderful that service\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionSet\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}EmotionSet\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotion\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Emotion\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionCategory\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}wna:negative\PYZhy{}fear\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionIntensity\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{0.06258366271018097}
\PY{p}{\PYZcb{}}\PY{p}{,}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Emotion\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionCategory\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}wna:amusement\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionIntensity\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{0.15784834034155437}
\PY{p}{\PYZcb{}}\PY{p}{,}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Emotion\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionCategory\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}wna:anger\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionIntensity\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{0.08728815135373413}
\PY{p}{\PYZcb{}}\PY{p}{,}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Emotion\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionCategory\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}wna:annoyance\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionIntensity\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{0.12184635680460143}
\PY{p}{\PYZcb{}}\PY{p}{,}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Emotion\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionCategory\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}wna:indifference\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionIntensity\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{0.1374081151031531}
\PY{p}{\PYZcb{}}\PY{p}{,}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Emotion\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionCategory\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}wna:joy\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionIntensity\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{0.12267040802346799}
\PY{p}{\PYZcb{}}\PY{p}{,}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Emotion\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionCategory\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}wna:awe\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionIntensity\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{0.21085262130713067}
\PY{p}{\PYZcb{}}\PY{p}{,}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Emotion\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionCategory\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}wna:sadness\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionIntensity\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{0.09950234435617733}
\PY{p}{\PYZcb{}}
\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}prov:wasGeneratedBy\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}prefix:Analysis\PYZus{}1554389679.0535374\PYZdq{}}
\PY{p}{\PYZcb{}}
\PY{p}{]}
\PY{p}{\PYZcb{}}
\PY{p}{]}
\PY{p}{\PYZcb{}}
\end{Verbatim}
{
"@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tZGVwZWNoZW1vb2Q_aW5wdXQ9U2VucHkraXMrYSt3b25kZXJmdWwrdGhhdCtzZXJ2aWNlIw%3D%3D",
"@type": "Results",
"entries": [
{
"@id": "prefix:",
"@type": "Entry",
"marl:hasOpinion": [],
"nif:isString": "Senpy is a wonderful that service",
"onyx:hasEmotionSet": [
{
"@type": "EmotionSet",
"onyx:hasEmotion": [
{
"@type": "Emotion",
"onyx:hasEmotionCategory": "wna:negative-fear",
"onyx:hasEmotionIntensity": 0.06258366271018097
},
{
"@type": "Emotion",
"onyx:hasEmotionCategory": "wna:amusement",
"onyx:hasEmotionIntensity": 0.15784834034155437
},
{
"@type": "Emotion",
"onyx:hasEmotionCategory": "wna:anger",
"onyx:hasEmotionIntensity": 0.08728815135373413
},
{
"@type": "Emotion",
"onyx:hasEmotionCategory": "wna:annoyance",
"onyx:hasEmotionIntensity": 0.12184635680460143
},
{
"@type": "Emotion",
"onyx:hasEmotionCategory": "wna:indifference",
"onyx:hasEmotionIntensity": 0.1374081151031531
},
{
"@type": "Emotion",
"onyx:hasEmotionCategory": "wna:joy",
"onyx:hasEmotionIntensity": 0.12267040802346799
},
{
"@type": "Emotion",
"onyx:hasEmotionCategory": "wna:awe",
"onyx:hasEmotionIntensity": 0.21085262130713067
},
{
"@type": "Emotion",
"onyx:hasEmotionCategory": "wna:sadness",
"onyx:hasEmotionIntensity": 0.09950234435617733
}
],
"prov:wasGeneratedBy": "prefix:Analysis_1554389679.0535374"
}
]
}
]
}
%% Cell type:markdown id: tags:
As you have probably noticed, there are several emotions in this result, each with a different intensity.
We can also tell senpy to only return the emotion with the maximum intensity using the `maxemotion` parameter:
%% Cell type:code id: tags:
``` python
res = requests.get(f'{endpoint}/emotion-depechemood',
params={"input": "Senpy is a wonderful service",
"maxemotion": True})
pretty(res.text)
```
%%%% Output: execute_result
\begin{Verbatim}[commandchars=\\\{\}]
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@context\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tZGVwZWNoZW1vb2Q\PYZus{}aW5wdXQ9U2VucHkraXMrYSt3b25kZXJmdWwrc2VydmljZSZtYXhlbW90aW9uPVRydWUj\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Results\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}entries\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@id\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}prefix:\PYZdq{}}\PY{p}{,}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Entry\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}marl:hasOpinion\PYZdq{}}\PY{p}{:} \PY{p}{[}\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}nif:isString\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Senpy is a wonderful service\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionSet\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}EmotionSet\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotion\PYZdq{}}\PY{p}{:} \PY{p}{[}
\PY{p}{\PYZob{}}
\PY{n+nd}{\PYZdq{}@type\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}Emotion\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionCategory\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}wna:awe\PYZdq{}}\PY{p}{,}
\PY{n+nt}{\PYZdq{}onyx:hasEmotionIntensity\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{0.21085262130713067}
\PY{p}{\PYZcb{}}
\PY{p}{]}\PY{p}{,}
\PY{n+nt}{\PYZdq{}prov:wasGeneratedBy\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}prefix:Analysis\PYZus{}1554389681.1941268\PYZdq{}}
\PY{p}{\PYZcb{}}
\PY{p}{]}
\PY{p}{\PYZcb{}}
\PY{p}{]}
\PY{p}{\PYZcb{}}
\end{Verbatim}
{
"@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tZGVwZWNoZW1vb2Q_aW5wdXQ9U2VucHkraXMrYSt3b25kZXJmdWwrc2VydmljZSZtYXhlbW90aW9uPVRydWUj",
"@type": "Results",
"entries": [
{
"@id": "prefix:",
"@type": "Entry",
"marl:hasOpinion": [],
"nif:isString": "Senpy is a wonderful service",
"onyx:hasEmotionSet": [
{
"@type": "EmotionSet",
"onyx:hasEmotion": [
{
"@type": "Emotion",
"onyx:hasEmotionCategory": "wna:awe",
"onyx:hasEmotionIntensity": 0.21085262130713067
}
],
"prov:wasGeneratedBy": "prefix:Analysis_1554389681.1941268"
}
]
}
]
}
%% Cell type:markdown id: tags:
## Other output formats
%% Cell type:markdown id: tags:
Senpy supports several semantic formats, like turtle and xml-RDF.
You can select the format of the output with the `outformat` parameter:
%% Cell type:code id: tags:
``` python
res = requests.get(f'{endpoint}/sentiment140',
params={"input": "Senpy is the best framework for semantic sentiment analysis, and very easy to use",
"outformat": "turtle"})
pretty(res.text, language='turtle')
```
%%%% Output: execute_result
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://www.gsi.upm.es/onto/senpy/ns\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{dc:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://dublincore.org/2012/06/14/dcelements\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{emoml:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/emotionml/ns\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{endpoint:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://senpy.gsi.upm.es/api/\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{fam:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://vocab.fusepool.info/fam\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{marl:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://www.gsi.dit.upm.es/ontologies/marl/ns\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{nif:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://persistence.uni\PYZhy{}leipzig.org/nlp2rdf/ontologies/nif\PYZhy{}core\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{onyx:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://www.gsi.dit.upm.es/ontologies/onyx/ns\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{prefix:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://senpy.invalid/\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{prov:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://www.w3.org/ns/prov\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{rdf:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://www.w3.org/1999/02/22\PYZhy{}rdf\PYZhy{}syntax\PYZhy{}ns\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{rdfs:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://www.w3.org/2000/01/rdf\PYZhy{}schema\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{senpy:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://www.gsi.upm.es/onto/senpy/ns\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{wna:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://www.gsi.dit.upm.es/ontologies/wnaffect/ns\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{xml:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://www.w3.org/XML/1998/namespace\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{k}{@prefix}\PY{+w}{ }\PY{n+nn}{xsd:}\PY{+w}{ }\PY{n+nv}{\PYZlt{}http://www.w3.org/2001/XMLSchema\PYZsh{}\PYZgt{}}\PY{+w}{ }\PY{p}{.}
\PY{err}{p}\PY{err}{r}\PY{err}{e}\PY{err}{f}\PY{err}{i}\PY{err}{x}\PY{p}{:}\PY{+w}{ }\PY{k+kt}{a}\PY{+w}{ }\PY{n+nn}{senpy:}\PY{n+nt}{Entry}\PY{+w}{ }\PY{p}{;}
\PY{+w}{ }\PY{n+nn}{nif:}\PY{n+nt}{isString}\PY{+w}{ }\PY{l+s}{\PYZdq{}}\PY{l+s}{Senpy is the best framework for semantic sentiment analysis, and very easy to use}\PY{l+s}{\PYZdq{}}\PY{+w}{ }\PY{p}{;}
\PY{+w}{ }\PY{n+nn}{marl:}\PY{n+nt}{hasOpinion}\PY{+w}{ }\PY{p}{[}\PY{+w}{ }\PY{k+kt}{a}\PY{+w}{ }\PY{n+nn}{senpy:}\PY{n+nt}{Sentiment}\PY{+w}{ }\PY{p}{;}
\PY{+w}{ }\PY{n+nn}{marl:}\PY{n+nt}{hasPolarity}\PY{+w}{ }\PY{l+s}{\PYZdq{}}\PY{l+s}{marl:Positive}\PY{l+s}{\PYZdq{}}\PY{+w}{ }\PY{p}{;}
\PY{+w}{ }\PY{n+nn}{prov:}\PY{n+nt}{wasGeneratedBy}\PY{+w}{ }\PY{n+nn}{prefix:}\PY{n+nt}{Analysis\PYZus{}1554389682}\PY{l+m+mf}{.350598}\PY{+w}{ }\PY{p}{]}\PY{+w}{ }\PY{p}{.}
\PY{p}{[}\PY{p}{]}\PY{+w}{ }\PY{k+kt}{a}\PY{+w}{ }\PY{n+nn}{senpy:}\PY{n+nt}{Results}\PY{+w}{ }\PY{p}{;}
\PY{+w}{ }\PY{n+nn}{prov:}\PY{n+nt}{used}\PY{+w}{ }\PY{err}{p}\PY{err}{r}\PY{err}{e}\PY{err}{f}\PY{err}{i}\PY{err}{x}\PY{p}{:}\PY{+w}{ }\PY{p}{.}
\end{Verbatim}
@prefix : <http://www.gsi.upm.es/onto/senpy/ns#> .
@prefix dc: <http://dublincore.org/2012/06/14/dcelements#> .
@prefix emoml: <http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/emotionml/ns#> .
@prefix endpoint: <http://senpy.gsi.upm.es/api/> .
@prefix fam: <http://vocab.fusepool.info/fam#> .
@prefix marl: <http://www.gsi.dit.upm.es/ontologies/marl/ns#> .
@prefix nif: <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .
@prefix onyx: <http://www.gsi.dit.upm.es/ontologies/onyx/ns#> .
@prefix prefix: <http://senpy.invalid/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix senpy: <http://www.gsi.upm.es/onto/senpy/ns#> .
@prefix wna: <http://www.gsi.dit.upm.es/ontologies/wnaffect/ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
prefix: a senpy:Entry ;
nif:isString "Senpy is the best framework for semantic sentiment analysis, and very easy to use" ;
marl:hasOpinion [ a senpy:Sentiment ;
marl:hasPolarity "marl:Positive" ;
prov:wasGeneratedBy prefix:Analysis_1554389682.350598 ] .
[] a senpy:Results ;
prov:used prefix: .
......
......@@ -6,8 +6,8 @@
"source": [
"# Senpy in 1 minute\n",
"\n",
"This mini-tutorial is the first in the series of senpy tutorials. It only shows how to annotate with a service.\n",
"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."
"This mini-tutorial only shows how to annotate with a service.\n",
"We will use the [demo server](http://senpy.gsi.upm.es), which runs some open source plugins for sentiment and emotion analysis."
]
},
{
......@@ -57,7 +57,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Congratulations, you've used your first senpy service!"
"**Congratulations**, you've used your first senpy service!"
]
},
{
......
%% 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.
This mini-tutorial only shows how to annotate with a service.
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!
**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": []
}
]
}
......
......@@ -83,6 +83,8 @@ language = None
# directories to ignore when looking for source files.
exclude_patterns = ['_build', '**.ipynb_checkpoints']
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
......
Welcome to Senpy's documentation!
=================================
.. image:: https://readthedocs.org/projects/senpy/badge/?version=latest
:target: http://senpy.readthedocs.io/en/latest/
:target: http://senpy.readthedocs.io/en/latest/
.. image:: https://badge.fury.io/py/senpy.svg
:target: https://badge.fury.io/py/senpy
:target: https://badge.fury.io/py/senpy
.. image:: https://lab.gsi.upm.es/senpy/senpy/badges/master/build.svg
:target: https://lab.gsi.upm.es/senpy/senpy/commits/master
:target: https://lab.gsi.upm.es/senpy/senpy/commits/master
.. image:: https://lab.gsi.upm.es/senpy/senpy/badges/master/coverage.svg
:target: https://lab.gsi.upm.es/senpy/senpy/commits/master
:target: https://lab.gsi.upm.es/senpy/senpy/commits/master
.. image:: https://img.shields.io/pypi/l/requests.svg
:target: https://lab.gsi.upm.es/senpy/senpy/
:target: https://lab.gsi.upm.es/senpy/senpy/
Senpy is a framework for sentiment and emotion analysis services.
......@@ -20,14 +20,16 @@ If you interested in consuming Senpy services, read :doc:`Quickstart`.
To get familiar with the concepts behind Senpy, and what it can offer for service developers, check out :doc:`development`.
:doc:`apischema` contains information about the semantic models and vocabularies used by Senpy.
.. toctree::
:caption: Learn more about senpy:
:maxdepth: 2
senpy
demo
Quickstart.ipynb
installation
apischema
advanced
publications
:caption: Learn more about senpy:
:maxdepth: 2
senpy
demo
Quickstart.ipynb
installation
apischema
advanced
publications
......@@ -18,10 +18,10 @@ And higher level features can be built on top of these services, such as automat
These benefits are not limited to new services.
The community has developed wrappers for some proprietary and commercial services (such as sentiment140 and Meaning Cloud), so you can consult them as.
Senpy comes with a :ref:`built-in client`.
Senpy comes with a built-in client in the client package.
To achieve this goal, Senpy uses a Linked Data principled approach, based on the NIF (NLP Interchange Format) specification, and open vocabularies such as Marl and Onyx.
You can learn more about this in :doc:`vocabularies`.
Check out :doc:`plugins` if you have developed an analysis algorithm (e.g. sentiment analysis) and you want to publish it as a service.
Check out :doc:`development` if you have developed an analysis algorithm (e.g. sentiment analysis) and you want to publish it as a service.
Supports Markdown
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