You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
senpy/docs/Quickstart-10minutes.ipynb

1514 lines
101 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Senpy in 10 minutes\n",
"\n",
"This tutorial assumes you have completed the [1 minute tutorial](Quickstart-1minute.ipynb) and you know how to access the API.\n",
"\n",
"It covers:\n",
"\n",
"* Annotating entiment with a sentiment analysis service\n",
"* Annotating emotions\n",
"* Interoperability of services\n",
"* Using other semantic formats (RDF)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Requirements"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once again, we will use the demo server at http://senpy.gsi.upm.es.\n",
"This time, we will use the requests library.\n",
"\n",
"We will use a variable for our endpoint, so you can try this examples on a different senpy instance:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"endpoint = 'http://senpy.gsi.upm.es/api'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will also add a function to get syntax highlighting for the JSON-LD/Turtle results:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" from IPython.display import Code\n",
" def pretty(txt, language='json-ld'):\n",
" return Code(txt, language=language)\n",
"except ImportError:\n",
" def pretty(txt, **kwargs):\n",
" print(txt)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sentiment Analysis of Text"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To start, let us analyse the sentiment in the following sentence: *senpy is awesome*.\n",
"\n",
"For now, we will use the [sentiment140](http://www.sentiment140.com/) service, through the sentiment140 plugin.\n",
"We will later cover how to use a different service.\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<style>.output_html .hll { background-color: #ffffcc }\n",
".output_html { background: #f8f8f8; }\n",
".output_html .c { color: #408080; font-style: italic } /* Comment */\n",
".output_html .err { border: 1px solid #FF0000 } /* Error */\n",
".output_html .k { color: #008000; font-weight: bold } /* Keyword */\n",
".output_html .o { color: #666666 } /* Operator */\n",
".output_html .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
".output_html .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
".output_html .cp { color: #BC7A00 } /* Comment.Preproc */\n",
".output_html .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
".output_html .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
".output_html .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
".output_html .gd { color: #A00000 } /* Generic.Deleted */\n",
".output_html .ge { font-style: italic } /* Generic.Emph */\n",
".output_html .gr { color: #FF0000 } /* Generic.Error */\n",
".output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
".output_html .gi { color: #00A000 } /* Generic.Inserted */\n",
".output_html .go { color: #888888 } /* Generic.Output */\n",
".output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
".output_html .gs { font-weight: bold } /* Generic.Strong */\n",
".output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
".output_html .gt { color: #0044DD } /* Generic.Traceback */\n",
".output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
".output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
".output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
".output_html .kp { color: #008000 } /* Keyword.Pseudo */\n",
".output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
".output_html .kt { color: #B00040 } /* Keyword.Type */\n",
".output_html .m { color: #666666 } /* Literal.Number */\n",
".output_html .s { color: #BA2121 } /* Literal.String */\n",
".output_html .na { color: #7D9029 } /* Name.Attribute */\n",
".output_html .nb { color: #008000 } /* Name.Builtin */\n",
".output_html .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
".output_html .no { color: #880000 } /* Name.Constant */\n",
".output_html .nd { color: #AA22FF } /* Name.Decorator */\n",
".output_html .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
".output_html .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
".output_html .nf { color: #0000FF } /* Name.Function */\n",
".output_html .nl { color: #A0A000 } /* Name.Label */\n",
".output_html .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
".output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
".output_html .nv { color: #19177C } /* Name.Variable */\n",
".output_html .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
".output_html .w { color: #bbbbbb } /* Text.Whitespace */\n",
".output_html .mb { color: #666666 } /* Literal.Number.Bin */\n",
".output_html .mf { color: #666666 } /* Literal.Number.Float */\n",
".output_html .mh { color: #666666 } /* Literal.Number.Hex */\n",
".output_html .mi { color: #666666 } /* Literal.Number.Integer */\n",
".output_html .mo { color: #666666 } /* Literal.Number.Oct */\n",
".output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n",
".output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
".output_html .sc { color: #BA2121 } /* Literal.String.Char */\n",
".output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
".output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
".output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n",
".output_html .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
".output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
".output_html .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
".output_html .sx { color: #008000 } /* Literal.String.Other */\n",
".output_html .sr { color: #BB6688 } /* Literal.String.Regex */\n",
".output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n",
".output_html .ss { color: #19177C } /* Literal.String.Symbol */\n",
".output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
".output_html .fm { color: #0000FF } /* Name.Function.Magic */\n",
".output_html .vc { color: #19177C } /* Name.Variable.Class */\n",
".output_html .vg { color: #19177C } /* Name.Variable.Global */\n",
".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n",
".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n",
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@context&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lIw%3D%3D&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Results&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;entries&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@id&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;prefix:&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Entry&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;marl:hasOpinion&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <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=\"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",
" <span class=\"nt\">&quot;onyx:hasEmotionSet&quot;</span><span class=\"p\">:</span> <span class=\"p\">[]</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">]</span>\n",
"<span class=\"p\">}</span>\n",
"</pre></div>\n"
],
"text/latex": [
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
"\\PY{p}{\\PYZob{}}\n",
" \\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}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Results\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}entries\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Entry\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}marl:hasOpinion\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\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{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",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionSet\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\\PY{p}{]}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\n",
"\\PY{p}{\\PYZcb{}}\n",
"\\end{Verbatim}\n"
],
"text/plain": [
"{\n",
" \"@context\": \"http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lIw%3D%3D\",\n",
" \"@type\": \"Results\",\n",
" \"entries\": [\n",
" {\n",
" \"@id\": \"prefix:\",\n",
" \"@type\": \"Entry\",\n",
" \"marl:hasOpinion\": [\n",
" {\n",
" \"@type\": \"Sentiment\",\n",
" \"marl:hasPolarity\": \"marl:Positive\",\n",
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1554391718.7649393\"\n",
" }\n",
" ],\n",
" \"nif:isString\": \"Senpy is awesome\",\n",
" \"onyx:hasEmotionSet\": []\n",
" }\n",
" ]\n",
"}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"res = requests.get(f'{endpoint}/sentiment140',\n",
" params={\"input\": \"Senpy is awesome\",})\n",
"pretty(res.text)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Senpy services always return an object of type `senpy:Results`, with a list of entries.\n",
"You can think of an entry as a self-contained textual context (`nif:Context` and `senpy:Entry`).\n",
"Entries can be as short as a sentence, or as long as a news article.\n",
"\n",
"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.\n",
"\n",
"For instance, sentiment annotations are provided through `marl:hasOpinion`.\n",
"\n",
"The annotations are semantic.\n",
"We can ask Senpy for the expanded JSON-LD output to reveal the full URIs of each property and entity:"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<style>.output_html .hll { background-color: #ffffcc }\n",
".output_html { background: #f8f8f8; }\n",
".output_html .c { color: #408080; font-style: italic } /* Comment */\n",
".output_html .err { border: 1px solid #FF0000 } /* Error */\n",
".output_html .k { color: #008000; font-weight: bold } /* Keyword */\n",
".output_html .o { color: #666666 } /* Operator */\n",
".output_html .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
".output_html .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
".output_html .cp { color: #BC7A00 } /* Comment.Preproc */\n",
".output_html .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
".output_html .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
".output_html .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
".output_html .gd { color: #A00000 } /* Generic.Deleted */\n",
".output_html .ge { font-style: italic } /* Generic.Emph */\n",
".output_html .gr { color: #FF0000 } /* Generic.Error */\n",
".output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
".output_html .gi { color: #00A000 } /* Generic.Inserted */\n",
".output_html .go { color: #888888 } /* Generic.Output */\n",
".output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
".output_html .gs { font-weight: bold } /* Generic.Strong */\n",
".output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
".output_html .gt { color: #0044DD } /* Generic.Traceback */\n",
".output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
".output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
".output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
".output_html .kp { color: #008000 } /* Keyword.Pseudo */\n",
".output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
".output_html .kt { color: #B00040 } /* Keyword.Type */\n",
".output_html .m { color: #666666 } /* Literal.Number */\n",
".output_html .s { color: #BA2121 } /* Literal.String */\n",
".output_html .na { color: #7D9029 } /* Name.Attribute */\n",
".output_html .nb { color: #008000 } /* Name.Builtin */\n",
".output_html .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
".output_html .no { color: #880000 } /* Name.Constant */\n",
".output_html .nd { color: #AA22FF } /* Name.Decorator */\n",
".output_html .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
".output_html .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
".output_html .nf { color: #0000FF } /* Name.Function */\n",
".output_html .nl { color: #A0A000 } /* Name.Label */\n",
".output_html .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
".output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
".output_html .nv { color: #19177C } /* Name.Variable */\n",
".output_html .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
".output_html .w { color: #bbbbbb } /* Text.Whitespace */\n",
".output_html .mb { color: #666666 } /* Literal.Number.Bin */\n",
".output_html .mf { color: #666666 } /* Literal.Number.Float */\n",
".output_html .mh { color: #666666 } /* Literal.Number.Hex */\n",
".output_html .mi { color: #666666 } /* Literal.Number.Integer */\n",
".output_html .mo { color: #666666 } /* Literal.Number.Oct */\n",
".output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n",
".output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
".output_html .sc { color: #BA2121 } /* Literal.String.Char */\n",
".output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
".output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
".output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n",
".output_html .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
".output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
".output_html .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
".output_html .sx { color: #008000 } /* Literal.String.Other */\n",
".output_html .sr { color: #BB6688 } /* Literal.String.Regex */\n",
".output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n",
".output_html .ss { color: #19177C } /* Literal.String.Symbol */\n",
".output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
".output_html .fm { color: #0000FF } /* Name.Function.Magic */\n",
".output_html .vc { color: #19177C } /* Name.Variable.Class */\n",
".output_html .vg { color: #19177C } /* Name.Variable.Global */\n",
".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n",
".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n",
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@context&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lJmV4cGFuZGVkPVRydWUj&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"s2\">&quot;http://www.gsi.upm.es/onto/senpy/ns#Results&quot;</span>\n",
" <span class=\"p\">],</span>\n",
" <span class=\"nt\">&quot;http://www.w3.org/ns/prov#used&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@id&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;http://senpy.invalid/&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"s2\">&quot;http://www.gsi.upm.es/onto/senpy/ns#Entry&quot;</span>\n",
" <span class=\"p\">],</span>\n",
" <span class=\"nt\">&quot;http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#isString&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@value&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Senpy is awesome&quot;</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">],</span>\n",
" <span class=\"nt\">&quot;http://www.gsi.dit.upm.es/ontologies/marl/ns#hasOpinion&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"s2\">&quot;http://www.gsi.upm.es/onto/senpy/ns#Sentiment&quot;</span>\n",
" <span class=\"p\">],</span>\n",
" <span class=\"nt\">&quot;http://www.gsi.dit.upm.es/ontologies/marl/ns#hasPolarity&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@value&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;marl:Positive&quot;</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">],</span>\n",
" <span class=\"nt\">&quot;http://www.w3.org/ns/prov#wasGeneratedBy&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@id&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;http://senpy.invalid/Analysis_1554389672.269198&quot;</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">]</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">],</span>\n",
" <span class=\"nt\">&quot;http://www.gsi.dit.upm.es/ontologies/onyx/ns#hasEmotionSet&quot;</span><span class=\"p\">:</span> <span class=\"p\">[]</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">]</span>\n",
"<span class=\"p\">}</span>\n",
"</pre></div>\n"
],
"text/latex": [
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
"\\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@context\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lJmV4cGFuZGVkPVRydWUj\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{l+s+s2}{\\PYZdq{}http://www.gsi.upm.es/onto/senpy/ns\\PYZsh{}Results\\PYZdq{}}\n",
" \\PY{p}{]}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}http://www.w3.org/ns/prov\\PYZsh{}used\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}http://senpy.invalid/\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{l+s+s2}{\\PYZdq{}http://www.gsi.upm.es/onto/senpy/ns\\PYZsh{}Entry\\PYZdq{}}\n",
" \\PY{p}{]}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}http://persistence.uni\\PYZhy{}leipzig.org/nlp2rdf/ontologies/nif\\PYZhy{}core\\PYZsh{}isString\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@value\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Senpy is awesome\\PYZdq{}}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/marl/ns\\PYZsh{}hasOpinion\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{l+s+s2}{\\PYZdq{}http://www.gsi.upm.es/onto/senpy/ns\\PYZsh{}Sentiment\\PYZdq{}}\n",
" \\PY{p}{]}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/marl/ns\\PYZsh{}hasPolarity\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@value\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}marl:Positive\\PYZdq{}}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}http://www.w3.org/ns/prov\\PYZsh{}wasGeneratedBy\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}http://senpy.invalid/Analysis\\PYZus{}1554389672.269198\\PYZdq{}}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/onyx/ns\\PYZsh{}hasEmotionSet\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\\PY{p}{]}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\n",
"\\PY{p}{\\PYZcb{}}\n",
"\\end{Verbatim}\n"
],
"text/plain": [
"{\n",
" \"@context\": \"http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lJmV4cGFuZGVkPVRydWUj\",\n",
" \"@type\": [\n",
" \"http://www.gsi.upm.es/onto/senpy/ns#Results\"\n",
" ],\n",
" \"http://www.w3.org/ns/prov#used\": [\n",
" {\n",
" \"@id\": \"http://senpy.invalid/\",\n",
" \"@type\": [\n",
" \"http://www.gsi.upm.es/onto/senpy/ns#Entry\"\n",
" ],\n",
" \"http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#isString\": [\n",
" {\n",
" \"@value\": \"Senpy is awesome\"\n",
" }\n",
" ],\n",
" \"http://www.gsi.dit.upm.es/ontologies/marl/ns#hasOpinion\": [\n",
" {\n",
" \"@type\": [\n",
" \"http://www.gsi.upm.es/onto/senpy/ns#Sentiment\"\n",
" ],\n",
" \"http://www.gsi.dit.upm.es/ontologies/marl/ns#hasPolarity\": [\n",
" {\n",
" \"@value\": \"marl:Positive\"\n",
" }\n",
" ],\n",
" \"http://www.w3.org/ns/prov#wasGeneratedBy\": [\n",
" {\n",
" \"@id\": \"http://senpy.invalid/Analysis_1554389672.269198\"\n",
" }\n",
" ]\n",
" }\n",
" ],\n",
" \"http://www.gsi.dit.upm.es/ontologies/onyx/ns#hasEmotionSet\": []\n",
" }\n",
" ]\n",
"}"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"res = requests.get(f'{endpoint}/sentiment140',\n",
" params={\"input\": \"Senpy is awesome\",\n",
" \"expanded\": True})\n",
"pretty(res.text)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Service interoperability"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"All senpy plugins use the same API, which makes moving from one service to another a breeze.\n",
"\n",
"Let us go back to our simple example, which uses the `sentiment140` service."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<style>.output_html .hll { background-color: #ffffcc }\n",
".output_html { background: #f8f8f8; }\n",
".output_html .c { color: #408080; font-style: italic } /* Comment */\n",
".output_html .err { border: 1px solid #FF0000 } /* Error */\n",
".output_html .k { color: #008000; font-weight: bold } /* Keyword */\n",
".output_html .o { color: #666666 } /* Operator */\n",
".output_html .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
".output_html .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
".output_html .cp { color: #BC7A00 } /* Comment.Preproc */\n",
".output_html .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
".output_html .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
".output_html .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
".output_html .gd { color: #A00000 } /* Generic.Deleted */\n",
".output_html .ge { font-style: italic } /* Generic.Emph */\n",
".output_html .gr { color: #FF0000 } /* Generic.Error */\n",
".output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
".output_html .gi { color: #00A000 } /* Generic.Inserted */\n",
".output_html .go { color: #888888 } /* Generic.Output */\n",
".output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
".output_html .gs { font-weight: bold } /* Generic.Strong */\n",
".output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
".output_html .gt { color: #0044DD } /* Generic.Traceback */\n",
".output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
".output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
".output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
".output_html .kp { color: #008000 } /* Keyword.Pseudo */\n",
".output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
".output_html .kt { color: #B00040 } /* Keyword.Type */\n",
".output_html .m { color: #666666 } /* Literal.Number */\n",
".output_html .s { color: #BA2121 } /* Literal.String */\n",
".output_html .na { color: #7D9029 } /* Name.Attribute */\n",
".output_html .nb { color: #008000 } /* Name.Builtin */\n",
".output_html .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
".output_html .no { color: #880000 } /* Name.Constant */\n",
".output_html .nd { color: #AA22FF } /* Name.Decorator */\n",
".output_html .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
".output_html .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
".output_html .nf { color: #0000FF } /* Name.Function */\n",
".output_html .nl { color: #A0A000 } /* Name.Label */\n",
".output_html .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
".output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
".output_html .nv { color: #19177C } /* Name.Variable */\n",
".output_html .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
".output_html .w { color: #bbbbbb } /* Text.Whitespace */\n",
".output_html .mb { color: #666666 } /* Literal.Number.Bin */\n",
".output_html .mf { color: #666666 } /* Literal.Number.Float */\n",
".output_html .mh { color: #666666 } /* Literal.Number.Hex */\n",
".output_html .mi { color: #666666 } /* Literal.Number.Integer */\n",
".output_html .mo { color: #666666 } /* Literal.Number.Oct */\n",
".output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n",
".output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
".output_html .sc { color: #BA2121 } /* Literal.String.Char */\n",
".output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
".output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
".output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n",
".output_html .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
".output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
".output_html .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
".output_html .sx { color: #008000 } /* Literal.String.Other */\n",
".output_html .sr { color: #BB6688 } /* Literal.String.Regex */\n",
".output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n",
".output_html .ss { color: #19177C } /* Literal.String.Symbol */\n",
".output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
".output_html .fm { color: #0000FF } /* Name.Function.Magic */\n",
".output_html .vc { color: #19177C } /* Name.Variable.Class */\n",
".output_html .vg { color: #19177C } /* Name.Variable.Global */\n",
".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n",
".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n",
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@context&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lIw%3D%3D&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Results&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;entries&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@id&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;prefix:&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Entry&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;marl:hasOpinion&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <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_1554389675.2303865&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",
" <span class=\"nt\">&quot;onyx:hasEmotionSet&quot;</span><span class=\"p\">:</span> <span class=\"p\">[]</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">]</span>\n",
"<span class=\"p\">}</span>\n",
"</pre></div>\n"
],
"text/latex": [
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
"\\PY{p}{\\PYZob{}}\n",
" \\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}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Results\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}entries\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Entry\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}marl:hasOpinion\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\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{}1554389675.2303865\\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",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionSet\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\\PY{p}{]}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\n",
"\\PY{p}{\\PYZcb{}}\n",
"\\end{Verbatim}\n"
],
"text/plain": [
"{\n",
" \"@context\": \"http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lIw%3D%3D\",\n",
" \"@type\": \"Results\",\n",
" \"entries\": [\n",
" {\n",
" \"@id\": \"prefix:\",\n",
" \"@type\": \"Entry\",\n",
" \"marl:hasOpinion\": [\n",
" {\n",
" \"@type\": \"Sentiment\",\n",
" \"marl:hasPolarity\": \"marl:Positive\",\n",
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1554389675.2303865\"\n",
" }\n",
" ],\n",
" \"nif:isString\": \"Senpy is awesome\",\n",
" \"onyx:hasEmotionSet\": []\n",
" }\n",
" ]\n",
"}"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"res = requests.get(f'{endpoint}/sentiment140',\n",
" params={\"input\": \"Senpy is awesome\"})\n",
"pretty(res.text)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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",
"execution_count": 15,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"<style>.output_html .hll { background-color: #ffffcc }\n",
".output_html { background: #f8f8f8; }\n",
".output_html .c { color: #408080; font-style: italic } /* Comment */\n",
".output_html .err { border: 1px solid #FF0000 } /* Error */\n",
".output_html .k { color: #008000; font-weight: bold } /* Keyword */\n",
".output_html .o { color: #666666 } /* Operator */\n",
".output_html .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
".output_html .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
".output_html .cp { color: #BC7A00 } /* Comment.Preproc */\n",
".output_html .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
".output_html .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
".output_html .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
".output_html .gd { color: #A00000 } /* Generic.Deleted */\n",
".output_html .ge { font-style: italic } /* Generic.Emph */\n",
".output_html .gr { color: #FF0000 } /* Generic.Error */\n",
".output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
".output_html .gi { color: #00A000 } /* Generic.Inserted */\n",
".output_html .go { color: #888888 } /* Generic.Output */\n",
".output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
".output_html .gs { font-weight: bold } /* Generic.Strong */\n",
".output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
".output_html .gt { color: #0044DD } /* Generic.Traceback */\n",
".output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
".output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
".output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
".output_html .kp { color: #008000 } /* Keyword.Pseudo */\n",
".output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
".output_html .kt { color: #B00040 } /* Keyword.Type */\n",
".output_html .m { color: #666666 } /* Literal.Number */\n",
".output_html .s { color: #BA2121 } /* Literal.String */\n",
".output_html .na { color: #7D9029 } /* Name.Attribute */\n",
".output_html .nb { color: #008000 } /* Name.Builtin */\n",
".output_html .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
".output_html .no { color: #880000 } /* Name.Constant */\n",
".output_html .nd { color: #AA22FF } /* Name.Decorator */\n",
".output_html .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
".output_html .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
".output_html .nf { color: #0000FF } /* Name.Function */\n",
".output_html .nl { color: #A0A000 } /* Name.Label */\n",
".output_html .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
".output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
".output_html .nv { color: #19177C } /* Name.Variable */\n",
".output_html .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
".output_html .w { color: #bbbbbb } /* Text.Whitespace */\n",
".output_html .mb { color: #666666 } /* Literal.Number.Bin */\n",
".output_html .mf { color: #666666 } /* Literal.Number.Float */\n",
".output_html .mh { color: #666666 } /* Literal.Number.Hex */\n",
".output_html .mi { color: #666666 } /* Literal.Number.Integer */\n",
".output_html .mo { color: #666666 } /* Literal.Number.Oct */\n",
".output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n",
".output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
".output_html .sc { color: #BA2121 } /* Literal.String.Char */\n",
".output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
".output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
".output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n",
".output_html .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
".output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
".output_html .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
".output_html .sx { color: #008000 } /* Literal.String.Other */\n",
".output_html .sr { color: #BB6688 } /* Literal.String.Regex */\n",
".output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n",
".output_html .ss { color: #19177C } /* Literal.String.Symbol */\n",
".output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
".output_html .fm { color: #0000FF } /* Name.Function.Magic */\n",
".output_html .vc { color: #19177C } /* Name.Variable.Class */\n",
".output_html .vg { color: #19177C } /* Name.Variable.Global */\n",
".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n",
".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n",
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@context&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudC1iYXNpYz9pbnB1dD1TZW5weStpcythd2Vzb21lIw%3D%3D&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Results&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;entries&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@id&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;prefix:&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Entry&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;marl:hasOpinion&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <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:Neutral&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_1554389675.9911203&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",
" <span class=\"nt\">&quot;onyx:hasEmotionSet&quot;</span><span class=\"p\">:</span> <span class=\"p\">[]</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">]</span>\n",
"<span class=\"p\">}</span>\n",
"</pre></div>\n"
],
"text/latex": [
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
"\\PY{p}{\\PYZob{}}\n",
" \\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}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Results\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}entries\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Entry\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}marl:hasOpinion\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\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:Neutral\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}prov:wasGeneratedBy\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:Analysis\\PYZus{}1554389675.9911203\\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",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionSet\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\\PY{p}{]}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\n",
"\\PY{p}{\\PYZcb{}}\n",
"\\end{Verbatim}\n"
],
"text/plain": [
"{\n",
" \"@context\": \"http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudC1iYXNpYz9pbnB1dD1TZW5weStpcythd2Vzb21lIw%3D%3D\",\n",
" \"@type\": \"Results\",\n",
" \"entries\": [\n",
" {\n",
" \"@id\": \"prefix:\",\n",
" \"@type\": \"Entry\",\n",
" \"marl:hasOpinion\": [\n",
" {\n",
" \"@type\": \"Sentiment\",\n",
" \"marl:hasPolarity\": \"marl:Neutral\",\n",
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1554389675.9911203\"\n",
" }\n",
" ],\n",
" \"nif:isString\": \"Senpy is awesome\",\n",
" \"onyx:hasEmotionSet\": []\n",
" }\n",
" ]\n",
"}"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"res = requests.get(f'{endpoint}/sentiment-basic',\n",
" params={\"input\": \"Senpy is awesome\"})\n",
"pretty(res.text)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As you can see, the structure and annotation schema of the response is the same.\n",
"This makes it very easy to compare and migrate to different services.\n",
"\n",
"Service interoperability is not only useful for users.\n",
"It is also key for other features such as [automated evaluation](#Evaluation).\n",
"This is a compelling reason to adapt existing services to use the Senpy API.\n",
"In fact, the `sentiment140` senpy service is proxy to the public [Sentiment 140 service](http://www.sentiment140.com/)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Emotion analysis"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"Senpy uses the `onyx` vocabulary to represent emotions, which incorporates the notion of `EmotionSet`'s, an emotion that is composed of several emotions.\n",
"In a nutshell, an `Entry` is linked to one or more `EmotionSet`, which in turn is made up of one or more `Emotion`.\n",
"\n",
"Let's illustrate it with an example, using the `emotion-depechemood` plugin."
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<style>.output_html .hll { background-color: #ffffcc }\n",
".output_html { background: #f8f8f8; }\n",
".output_html .c { color: #408080; font-style: italic } /* Comment */\n",
".output_html .err { border: 1px solid #FF0000 } /* Error */\n",
".output_html .k { color: #008000; font-weight: bold } /* Keyword */\n",
".output_html .o { color: #666666 } /* Operator */\n",
".output_html .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
".output_html .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
".output_html .cp { color: #BC7A00 } /* Comment.Preproc */\n",
".output_html .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
".output_html .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
".output_html .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
".output_html .gd { color: #A00000 } /* Generic.Deleted */\n",
".output_html .ge { font-style: italic } /* Generic.Emph */\n",
".output_html .gr { color: #FF0000 } /* Generic.Error */\n",
".output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
".output_html .gi { color: #00A000 } /* Generic.Inserted */\n",
".output_html .go { color: #888888 } /* Generic.Output */\n",
".output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
".output_html .gs { font-weight: bold } /* Generic.Strong */\n",
".output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
".output_html .gt { color: #0044DD } /* Generic.Traceback */\n",
".output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
".output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
".output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
".output_html .kp { color: #008000 } /* Keyword.Pseudo */\n",
".output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
".output_html .kt { color: #B00040 } /* Keyword.Type */\n",
".output_html .m { color: #666666 } /* Literal.Number */\n",
".output_html .s { color: #BA2121 } /* Literal.String */\n",
".output_html .na { color: #7D9029 } /* Name.Attribute */\n",
".output_html .nb { color: #008000 } /* Name.Builtin */\n",
".output_html .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
".output_html .no { color: #880000 } /* Name.Constant */\n",
".output_html .nd { color: #AA22FF } /* Name.Decorator */\n",
".output_html .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
".output_html .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
".output_html .nf { color: #0000FF } /* Name.Function */\n",
".output_html .nl { color: #A0A000 } /* Name.Label */\n",
".output_html .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
".output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
".output_html .nv { color: #19177C } /* Name.Variable */\n",
".output_html .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
".output_html .w { color: #bbbbbb } /* Text.Whitespace */\n",
".output_html .mb { color: #666666 } /* Literal.Number.Bin */\n",
".output_html .mf { color: #666666 } /* Literal.Number.Float */\n",
".output_html .mh { color: #666666 } /* Literal.Number.Hex */\n",
".output_html .mi { color: #666666 } /* Literal.Number.Integer */\n",
".output_html .mo { color: #666666 } /* Literal.Number.Oct */\n",
".output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n",
".output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
".output_html .sc { color: #BA2121 } /* Literal.String.Char */\n",
".output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
".output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
".output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n",
".output_html .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
".output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
".output_html .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
".output_html .sx { color: #008000 } /* Literal.String.Other */\n",
".output_html .sr { color: #BB6688 } /* Literal.String.Regex */\n",
".output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n",
".output_html .ss { color: #19177C } /* Literal.String.Symbol */\n",
".output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
".output_html .fm { color: #0000FF } /* Name.Function.Magic */\n",
".output_html .vc { color: #19177C } /* Name.Variable.Class */\n",
".output_html .vg { color: #19177C } /* Name.Variable.Global */\n",
".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n",
".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n",
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@context&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tZGVwZWNoZW1vb2Q_aW5wdXQ9U2VucHkraXMrYSt3b25kZXJmdWwrdGhhdCtzZXJ2aWNlIw%3D%3D&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Results&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;entries&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@id&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;prefix:&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Entry&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;marl:hasOpinion&quot;</span><span class=\"p\">:</span> <span class=\"p\">[],</span>\n",
" <span class=\"nt\">&quot;nif:isString&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Senpy is a wonderful that service&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionSet&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;EmotionSet&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotion&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Emotion&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionCategory&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;wna:negative-fear&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionIntensity&quot;</span><span class=\"p\">:</span> <span class=\"mf\">0.06258366271018097</span>\n",
" <span class=\"p\">},</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Emotion&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionCategory&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;wna:amusement&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionIntensity&quot;</span><span class=\"p\">:</span> <span class=\"mf\">0.15784834034155437</span>\n",
" <span class=\"p\">},</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Emotion&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionCategory&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;wna:anger&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionIntensity&quot;</span><span class=\"p\">:</span> <span class=\"mf\">0.08728815135373413</span>\n",
" <span class=\"p\">},</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Emotion&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionCategory&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;wna:annoyance&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionIntensity&quot;</span><span class=\"p\">:</span> <span class=\"mf\">0.12184635680460143</span>\n",
" <span class=\"p\">},</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Emotion&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionCategory&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;wna:indifference&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionIntensity&quot;</span><span class=\"p\">:</span> <span class=\"mf\">0.1374081151031531</span>\n",
" <span class=\"p\">},</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Emotion&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionCategory&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;wna:joy&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionIntensity&quot;</span><span class=\"p\">:</span> <span class=\"mf\">0.12267040802346799</span>\n",
" <span class=\"p\">},</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Emotion&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionCategory&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;wna:awe&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionIntensity&quot;</span><span class=\"p\">:</span> <span class=\"mf\">0.21085262130713067</span>\n",
" <span class=\"p\">},</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Emotion&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionCategory&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;wna:sadness&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionIntensity&quot;</span><span class=\"p\">:</span> <span class=\"mf\">0.09950234435617733</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">],</span>\n",
" <span class=\"nt\">&quot;prov:wasGeneratedBy&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;prefix:Analysis_1554389679.0535374&quot;</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">]</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">]</span>\n",
"<span class=\"p\">}</span>\n",
"</pre></div>\n"
],
"text/latex": [
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
"\\PY{p}{\\PYZob{}}\n",
" \\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}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Results\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}entries\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Entry\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}marl:hasOpinion\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\\PY{p}{]}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}nif:isString\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Senpy is a wonderful that service\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionSet\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}EmotionSet\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotion\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionCategory\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}wna:negative\\PYZhy{}fear\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionIntensity\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{0.06258366271018097}\n",
" \\PY{p}{\\PYZcb{}}\\PY{p}{,}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionCategory\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}wna:amusement\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionIntensity\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{0.15784834034155437}\n",
" \\PY{p}{\\PYZcb{}}\\PY{p}{,}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionCategory\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}wna:anger\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionIntensity\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{0.08728815135373413}\n",
" \\PY{p}{\\PYZcb{}}\\PY{p}{,}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionCategory\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}wna:annoyance\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionIntensity\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{0.12184635680460143}\n",
" \\PY{p}{\\PYZcb{}}\\PY{p}{,}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionCategory\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}wna:indifference\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionIntensity\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{0.1374081151031531}\n",
" \\PY{p}{\\PYZcb{}}\\PY{p}{,}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionCategory\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}wna:joy\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionIntensity\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{0.12267040802346799}\n",
" \\PY{p}{\\PYZcb{}}\\PY{p}{,}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionCategory\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}wna:awe\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionIntensity\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{0.21085262130713067}\n",
" \\PY{p}{\\PYZcb{}}\\PY{p}{,}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionCategory\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}wna:sadness\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionIntensity\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{0.09950234435617733}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}prov:wasGeneratedBy\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:Analysis\\PYZus{}1554389679.0535374\\PYZdq{}}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\n",
"\\PY{p}{\\PYZcb{}}\n",
"\\end{Verbatim}\n"
],
"text/plain": [
"{\n",
" \"@context\": \"http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tZGVwZWNoZW1vb2Q_aW5wdXQ9U2VucHkraXMrYSt3b25kZXJmdWwrdGhhdCtzZXJ2aWNlIw%3D%3D\",\n",
" \"@type\": \"Results\",\n",
" \"entries\": [\n",
" {\n",
" \"@id\": \"prefix:\",\n",
" \"@type\": \"Entry\",\n",
" \"marl:hasOpinion\": [],\n",
" \"nif:isString\": \"Senpy is a wonderful that service\",\n",
" \"onyx:hasEmotionSet\": [\n",
" {\n",
" \"@type\": \"EmotionSet\",\n",
" \"onyx:hasEmotion\": [\n",
" {\n",
" \"@type\": \"Emotion\",\n",
" \"onyx:hasEmotionCategory\": \"wna:negative-fear\",\n",
" \"onyx:hasEmotionIntensity\": 0.06258366271018097\n",
" },\n",
" {\n",
" \"@type\": \"Emotion\",\n",
" \"onyx:hasEmotionCategory\": \"wna:amusement\",\n",
" \"onyx:hasEmotionIntensity\": 0.15784834034155437\n",
" },\n",
" {\n",
" \"@type\": \"Emotion\",\n",
" \"onyx:hasEmotionCategory\": \"wna:anger\",\n",
" \"onyx:hasEmotionIntensity\": 0.08728815135373413\n",
" },\n",
" {\n",
" \"@type\": \"Emotion\",\n",
" \"onyx:hasEmotionCategory\": \"wna:annoyance\",\n",
" \"onyx:hasEmotionIntensity\": 0.12184635680460143\n",
" },\n",
" {\n",
" \"@type\": \"Emotion\",\n",
" \"onyx:hasEmotionCategory\": \"wna:indifference\",\n",
" \"onyx:hasEmotionIntensity\": 0.1374081151031531\n",
" },\n",
" {\n",
" \"@type\": \"Emotion\",\n",
" \"onyx:hasEmotionCategory\": \"wna:joy\",\n",
" \"onyx:hasEmotionIntensity\": 0.12267040802346799\n",
" },\n",
" {\n",
" \"@type\": \"Emotion\",\n",
" \"onyx:hasEmotionCategory\": \"wna:awe\",\n",
" \"onyx:hasEmotionIntensity\": 0.21085262130713067\n",
" },\n",
" {\n",
" \"@type\": \"Emotion\",\n",
" \"onyx:hasEmotionCategory\": \"wna:sadness\",\n",
" \"onyx:hasEmotionIntensity\": 0.09950234435617733\n",
" }\n",
" ],\n",
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1554389679.0535374\"\n",
" }\n",
" ]\n",
" }\n",
" ]\n",
"}"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res = requests.get(f'{endpoint}/emotion-depechemood',\n",
" params={\"input\": \"Senpy is a wonderful that service\"})\n",
"pretty(res.text)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As you have probably noticed, there are several emotions in this result, each with a different intensity.\n",
"\n",
"We can also tell senpy to only return the emotion with the maximum intensity using the `maxemotion` parameter:"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<style>.output_html .hll { background-color: #ffffcc }\n",
".output_html { background: #f8f8f8; }\n",
".output_html .c { color: #408080; font-style: italic } /* Comment */\n",
".output_html .err { border: 1px solid #FF0000 } /* Error */\n",
".output_html .k { color: #008000; font-weight: bold } /* Keyword */\n",
".output_html .o { color: #666666 } /* Operator */\n",
".output_html .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
".output_html .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
".output_html .cp { color: #BC7A00 } /* Comment.Preproc */\n",
".output_html .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
".output_html .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
".output_html .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
".output_html .gd { color: #A00000 } /* Generic.Deleted */\n",
".output_html .ge { font-style: italic } /* Generic.Emph */\n",
".output_html .gr { color: #FF0000 } /* Generic.Error */\n",
".output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
".output_html .gi { color: #00A000 } /* Generic.Inserted */\n",
".output_html .go { color: #888888 } /* Generic.Output */\n",
".output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
".output_html .gs { font-weight: bold } /* Generic.Strong */\n",
".output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
".output_html .gt { color: #0044DD } /* Generic.Traceback */\n",
".output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
".output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
".output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
".output_html .kp { color: #008000 } /* Keyword.Pseudo */\n",
".output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
".output_html .kt { color: #B00040 } /* Keyword.Type */\n",
".output_html .m { color: #666666 } /* Literal.Number */\n",
".output_html .s { color: #BA2121 } /* Literal.String */\n",
".output_html .na { color: #7D9029 } /* Name.Attribute */\n",
".output_html .nb { color: #008000 } /* Name.Builtin */\n",
".output_html .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
".output_html .no { color: #880000 } /* Name.Constant */\n",
".output_html .nd { color: #AA22FF } /* Name.Decorator */\n",
".output_html .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
".output_html .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
".output_html .nf { color: #0000FF } /* Name.Function */\n",
".output_html .nl { color: #A0A000 } /* Name.Label */\n",
".output_html .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
".output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
".output_html .nv { color: #19177C } /* Name.Variable */\n",
".output_html .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
".output_html .w { color: #bbbbbb } /* Text.Whitespace */\n",
".output_html .mb { color: #666666 } /* Literal.Number.Bin */\n",
".output_html .mf { color: #666666 } /* Literal.Number.Float */\n",
".output_html .mh { color: #666666 } /* Literal.Number.Hex */\n",
".output_html .mi { color: #666666 } /* Literal.Number.Integer */\n",
".output_html .mo { color: #666666 } /* Literal.Number.Oct */\n",
".output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n",
".output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
".output_html .sc { color: #BA2121 } /* Literal.String.Char */\n",
".output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
".output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
".output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n",
".output_html .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
".output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
".output_html .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
".output_html .sx { color: #008000 } /* Literal.String.Other */\n",
".output_html .sr { color: #BB6688 } /* Literal.String.Regex */\n",
".output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n",
".output_html .ss { color: #19177C } /* Literal.String.Symbol */\n",
".output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
".output_html .fm { color: #0000FF } /* Name.Function.Magic */\n",
".output_html .vc { color: #19177C } /* Name.Variable.Class */\n",
".output_html .vg { color: #19177C } /* Name.Variable.Global */\n",
".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n",
".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n",
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@context&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tZGVwZWNoZW1vb2Q_aW5wdXQ9U2VucHkraXMrYSt3b25kZXJmdWwrc2VydmljZSZtYXhlbW90aW9uPVRydWUj&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Results&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;entries&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@id&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;prefix:&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Entry&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;marl:hasOpinion&quot;</span><span class=\"p\">:</span> <span class=\"p\">[],</span>\n",
" <span class=\"nt\">&quot;nif:isString&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Senpy is a wonderful service&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionSet&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;EmotionSet&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotion&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
" <span class=\"p\">{</span>\n",
" <span class=\"nd\">&quot;@type&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Emotion&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionCategory&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;wna:awe&quot;</span><span class=\"p\">,</span>\n",
" <span class=\"nt\">&quot;onyx:hasEmotionIntensity&quot;</span><span class=\"p\">:</span> <span class=\"mf\">0.21085262130713067</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">],</span>\n",
" <span class=\"nt\">&quot;prov:wasGeneratedBy&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;prefix:Analysis_1554389681.1941268&quot;</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">]</span>\n",
" <span class=\"p\">}</span>\n",
" <span class=\"p\">]</span>\n",
"<span class=\"p\">}</span>\n",
"</pre></div>\n"
],
"text/latex": [
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
"\\PY{p}{\\PYZob{}}\n",
" \\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}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Results\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}entries\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Entry\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}marl:hasOpinion\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\\PY{p}{]}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}nif:isString\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Senpy is a wonderful service\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionSet\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}EmotionSet\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotion\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
" \\PY{p}{\\PYZob{}}\n",
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionCategory\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}wna:awe\\PYZdq{}}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionIntensity\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{0.21085262130713067}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\\PY{p}{,}\n",
" \\PY{n+nt}{\\PYZdq{}prov:wasGeneratedBy\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:Analysis\\PYZus{}1554389681.1941268\\PYZdq{}}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\n",
" \\PY{p}{\\PYZcb{}}\n",
" \\PY{p}{]}\n",
"\\PY{p}{\\PYZcb{}}\n",
"\\end{Verbatim}\n"
],
"text/plain": [
"{\n",
" \"@context\": \"http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tZGVwZWNoZW1vb2Q_aW5wdXQ9U2VucHkraXMrYSt3b25kZXJmdWwrc2VydmljZSZtYXhlbW90aW9uPVRydWUj\",\n",
" \"@type\": \"Results\",\n",
" \"entries\": [\n",
" {\n",
" \"@id\": \"prefix:\",\n",
" \"@type\": \"Entry\",\n",
" \"marl:hasOpinion\": [],\n",
" \"nif:isString\": \"Senpy is a wonderful service\",\n",
" \"onyx:hasEmotionSet\": [\n",
" {\n",
" \"@type\": \"EmotionSet\",\n",
" \"onyx:hasEmotion\": [\n",
" {\n",
" \"@type\": \"Emotion\",\n",
" \"onyx:hasEmotionCategory\": \"wna:awe\",\n",
" \"onyx:hasEmotionIntensity\": 0.21085262130713067\n",
" }\n",
" ],\n",
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1554389681.1941268\"\n",
" }\n",
" ]\n",
" }\n",
" ]\n",
"}"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res = requests.get(f'{endpoint}/emotion-depechemood',\n",
" params={\"input\": \"Senpy is a wonderful service\",\n",
" \"maxemotion\": True})\n",
"pretty(res.text)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Other output formats"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Senpy supports several semantic formats, like turtle and xml-RDF.\n",
"You can select the format of the output with the `outformat` parameter:"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<style>.output_html .hll { background-color: #ffffcc }\n",
".output_html { background: #f8f8f8; }\n",
".output_html .c { color: #408080; font-style: italic } /* Comment */\n",
".output_html .err { border: 1px solid #FF0000 } /* Error */\n",
".output_html .k { color: #008000; font-weight: bold } /* Keyword */\n",
".output_html .o { color: #666666 } /* Operator */\n",
".output_html .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
".output_html .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
".output_html .cp { color: #BC7A00 } /* Comment.Preproc */\n",
".output_html .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
".output_html .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
".output_html .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
".output_html .gd { color: #A00000 } /* Generic.Deleted */\n",
".output_html .ge { font-style: italic } /* Generic.Emph */\n",
".output_html .gr { color: #FF0000 } /* Generic.Error */\n",
".output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
".output_html .gi { color: #00A000 } /* Generic.Inserted */\n",
".output_html .go { color: #888888 } /* Generic.Output */\n",
".output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
".output_html .gs { font-weight: bold } /* Generic.Strong */\n",
".output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
".output_html .gt { color: #0044DD } /* Generic.Traceback */\n",
".output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
".output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
".output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
".output_html .kp { color: #008000 } /* Keyword.Pseudo */\n",
".output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
".output_html .kt { color: #B00040 } /* Keyword.Type */\n",
".output_html .m { color: #666666 } /* Literal.Number */\n",
".output_html .s { color: #BA2121 } /* Literal.String */\n",
".output_html .na { color: #7D9029 } /* Name.Attribute */\n",
".output_html .nb { color: #008000 } /* Name.Builtin */\n",
".output_html .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
".output_html .no { color: #880000 } /* Name.Constant */\n",
".output_html .nd { color: #AA22FF } /* Name.Decorator */\n",
".output_html .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
".output_html .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
".output_html .nf { color: #0000FF } /* Name.Function */\n",
".output_html .nl { color: #A0A000 } /* Name.Label */\n",
".output_html .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
".output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
".output_html .nv { color: #19177C } /* Name.Variable */\n",
".output_html .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
".output_html .w { color: #bbbbbb } /* Text.Whitespace */\n",
".output_html .mb { color: #666666 } /* Literal.Number.Bin */\n",
".output_html .mf { color: #666666 } /* Literal.Number.Float */\n",
".output_html .mh { color: #666666 } /* Literal.Number.Hex */\n",
".output_html .mi { color: #666666 } /* Literal.Number.Integer */\n",
".output_html .mo { color: #666666 } /* Literal.Number.Oct */\n",
".output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n",
".output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
".output_html .sc { color: #BA2121 } /* Literal.String.Char */\n",
".output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
".output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
".output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n",
".output_html .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
".output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
".output_html .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
".output_html .sx { color: #008000 } /* Literal.String.Other */\n",
".output_html .sr { color: #BB6688 } /* Literal.String.Regex */\n",
".output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n",
".output_html .ss { color: #19177C } /* Literal.String.Symbol */\n",
".output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
".output_html .fm { color: #0000FF } /* Name.Function.Magic */\n",
".output_html .vc { color: #19177C } /* Name.Variable.Class */\n",
".output_html .vg { color: #19177C } /* Name.Variable.Global */\n",
".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n",
".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n",
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://www.gsi.upm.es/onto/senpy/ns#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">dc:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://dublincore.org/2012/06/14/dcelements#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">emoml:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/emotionml/ns#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">endpoint:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://senpy.gsi.upm.es/api/&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">fam:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://vocab.fusepool.info/fam#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">marl:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://www.gsi.dit.upm.es/ontologies/marl/ns#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">nif:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">onyx:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://www.gsi.dit.upm.es/ontologies/onyx/ns#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">prefix:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://senpy.invalid/&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">prov:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://www.w3.org/ns/prov#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">rdf:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">rdfs:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://www.w3.org/2000/01/rdf-schema#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">senpy:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://www.gsi.upm.es/onto/senpy/ns#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">wna:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://www.gsi.dit.upm.es/ontologies/wnaffect/ns#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">xml:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://www.w3.org/XML/1998/namespace&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"<span class=\"k\">@prefix</span><span class=\"w\"> </span><span class=\"nn\">xsd:</span><span class=\"w\"> </span><span class=\"nv\">&lt;http://www.w3.org/2001/XMLSchema#&gt;</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"\n",
"<span class=\"err\">prefix</span><span class=\"p\">:</span><span class=\"w\"> </span><span class=\"kt\">a</span><span class=\"w\"> </span><span class=\"nn\">senpy:</span><span class=\"nt\">Entry</span><span class=\"w\"> </span><span class=\"p\">;</span><span class=\"w\"></span>\n",
"<span class=\"w\"> </span><span class=\"nn\">nif:</span><span class=\"nt\">isString</span><span class=\"w\"> </span><span class=\"s\">&quot;Senpy is the best framework for semantic sentiment analysis, and very easy to use&quot;</span><span class=\"w\"> </span><span class=\"p\">;</span><span class=\"w\"></span>\n",
"<span class=\"w\"> </span><span class=\"nn\">marl:</span><span class=\"nt\">hasOpinion</span><span class=\"w\"> </span><span class=\"p\">[</span><span class=\"w\"> </span><span class=\"kt\">a</span><span class=\"w\"> </span><span class=\"nn\">senpy:</span><span class=\"nt\">Sentiment</span><span class=\"w\"> </span><span class=\"p\">;</span><span class=\"w\"></span>\n",
"<span class=\"w\"> </span><span class=\"nn\">marl:</span><span class=\"nt\">hasPolarity</span><span class=\"w\"> </span><span class=\"s\">&quot;marl:Positive&quot;</span><span class=\"w\"> </span><span class=\"p\">;</span><span class=\"w\"></span>\n",
"<span class=\"w\"> </span><span class=\"nn\">prov:</span><span class=\"nt\">wasGeneratedBy</span><span class=\"w\"> </span><span class=\"nn\">prefix:</span><span class=\"nt\">Analysis_1554389682</span><span class=\"mf\">.350598</span><span class=\"w\"> </span><span class=\"p\">]</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"\n",
"<span class=\"p\">[]</span><span class=\"w\"> </span><span class=\"kt\">a</span><span class=\"w\"> </span><span class=\"nn\">senpy:</span><span class=\"nt\">Results</span><span class=\"w\"> </span><span class=\"p\">;</span><span class=\"w\"></span>\n",
"<span class=\"w\"> </span><span class=\"nn\">prov:</span><span class=\"nt\">used</span><span class=\"w\"> </span><span class=\"err\">prefix</span><span class=\"p\">:</span><span class=\"w\"> </span><span class=\"p\">.</span><span class=\"w\"></span>\n",
"</pre></div>\n"
],
"text/latex": [
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\PY{k}{@prefix}\\PY{+w}{ }\\PY{n+nn}{prefix:}\\PY{+w}{ }\\PY{n+nv}{\\PYZlt{}http://senpy.invalid/\\PYZgt{}}\\PY{+w}{ }\\PY{p}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\\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}{.}\n",
"\n",
"\\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}{;}\n",
"\\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}{;}\n",
"\\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}{;}\n",
"\\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}{;}\n",
"\\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}{.}\n",
"\n",
"\\PY{p}{[}\\PY{p}{]}\\PY{+w}{ }\\PY{k+kt}{a}\\PY{+w}{ }\\PY{n+nn}{senpy:}\\PY{n+nt}{Results}\\PY{+w}{ }\\PY{p}{;}\n",
"\\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}{.}\n",
"\\end{Verbatim}\n"
],
"text/plain": [
"@prefix : <http://www.gsi.upm.es/onto/senpy/ns#> .\n",
"@prefix dc: <http://dublincore.org/2012/06/14/dcelements#> .\n",
"@prefix emoml: <http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/emotionml/ns#> .\n",
"@prefix endpoint: <http://senpy.gsi.upm.es/api/> .\n",
"@prefix fam: <http://vocab.fusepool.info/fam#> .\n",
"@prefix marl: <http://www.gsi.dit.upm.es/ontologies/marl/ns#> .\n",
"@prefix nif: <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .\n",
"@prefix onyx: <http://www.gsi.dit.upm.es/ontologies/onyx/ns#> .\n",
"@prefix prefix: <http://senpy.invalid/> .\n",
"@prefix prov: <http://www.w3.org/ns/prov#> .\n",
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n",
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n",
"@prefix senpy: <http://www.gsi.upm.es/onto/senpy/ns#> .\n",
"@prefix wna: <http://www.gsi.dit.upm.es/ontologies/wnaffect/ns#> .\n",
"@prefix xml: <http://www.w3.org/XML/1998/namespace> .\n",
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n",
"\n",
"prefix: a senpy:Entry ;\n",
" nif:isString \"Senpy is the best framework for semantic sentiment analysis, and very easy to use\" ;\n",
" marl:hasOpinion [ a senpy:Sentiment ;\n",
" marl:hasPolarity \"marl:Positive\" ;\n",
" prov:wasGeneratedBy prefix:Analysis_1554389682.350598 ] .\n",
"\n",
"[] a senpy:Results ;\n",
" prov:used prefix: .\n"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res = requests.get(f'{endpoint}/sentiment140',\n",
" params={\"input\": \"Senpy is the best framework for semantic sentiment analysis, and very easy to use\",\n",
" \"outformat\": \"turtle\"})\n",
"pretty(res.text, language='turtle')"
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
},
"toc": {
"colors": {
"hover_highlight": "#DAA520",
"running_highlight": "#FF0000",
"selected_highlight": "#FFD700"
},
"moveMenuLeft": true,
"nav_menu": {
"height": "68px",
"width": "252px"
},
"navigate_menu": true,
"number_sections": true,
"sideBar": true,
"threshold": 4,
"toc_cell": false,
"toc_section_display": "block",
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 1
}