mirror of
https://github.com/gsi-upm/senpy
synced 2024-11-22 00:02:28 +00:00
1718 lines
119 KiB
Plaintext
1718 lines
119 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Tutorial\n",
|
|
"\n",
|
|
"This short tutorial will teach you how to consume senpy services for several tasks, and how to take advantage of the features of the framework.\n",
|
|
"\n",
|
|
"In particular, it covers:\n",
|
|
"\n",
|
|
"* Annotating text with sentiment and emotion using interoperable services\n",
|
|
"* Switching to different services (service interoperability)\n",
|
|
"* Getting results in different formats (Turtle, XML, text...)\n",
|
|
"* Asking for specific emotion models (automatic model conversion)\n",
|
|
"\n",
|
|
"The tutorial is originally published as an interactive [jupyter notebook](https://jupyter.org/) (`ipynb` file) that you can download and run locally.\n",
|
|
"The on-line documentation contains a **static** version of the notebook."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Requirements"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"We will use the demo server at http://senpy.gsi.upm.es and the requests library.\n",
|
|
"\n",
|
|
"We will use a variable for our endpoint.\n",
|
|
"To try these examples on other instances simply change the value of this variable and re-run the query:"
|
|
]
|
|
},
|
|
{
|
|
"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 little helper function (`query`) to simplify our queries and pretty-print the results with syntax highlighting:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import requests\n",
|
|
"from IPython.display import Code\n",
|
|
" \n",
|
|
"def query(endpoint, **kwargs):\n",
|
|
" '''Query a given Senpy endpoint with specific parameters, and prettify the output'''\n",
|
|
" res = requests.get(endpoint,\n",
|
|
" params=kwargs)\n",
|
|
" if res.status_code != 200:\n",
|
|
" raise Exception(res)\n",
|
|
" return Code(res.text, language=kwargs.get('outformat', 'json-ld'))"
|
|
]
|
|
},
|
|
{
|
|
"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\">"@context"</span><span class=\"p\">:</span> <span class=\"s2\">"http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lIw%3D%3D"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Results"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"entries"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Entry"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"marl:hasOpinion"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Sentiment"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"marl:hasPolarity"</span><span class=\"p\">:</span> <span class=\"s2\">"marl:Positive"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"prov:wasGeneratedBy"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:Analysis_1563372853.439696"</span>\n",
|
|
" <span class=\"p\">}</span>\n",
|
|
" <span class=\"p\">],</span>\n",
|
|
" <span class=\"nt\">"nif:isString"</span><span class=\"p\">:</span> <span class=\"s2\">"Senpy is awesome"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionSet"</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{}1563372853.439696\\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_1563372853.439696\"\n",
|
|
" }\n",
|
|
" ],\n",
|
|
" \"nif:isString\": \"Senpy is awesome\",\n",
|
|
" \"onyx:hasEmotionSet\": []\n",
|
|
" }\n",
|
|
" ]\n",
|
|
"}"
|
|
]
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"query(f'{endpoint}/sentiment140', input=\"Senpy is awesome\")"
|
|
]
|
|
},
|
|
{
|
|
"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",
|
|
"This is clear if we request a different semantic format, such as `turtle`.\n",
|
|
"The output format is controlled with the `outformat` parameter:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"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\"><http://www.gsi.upm.es/onto/senpy/ns#></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\"><http://dublincore.org/2012/06/14/dcelements#></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\"><http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/emotionml/ns#></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\"><http://senpy.gsi.upm.es/api/></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\"><http://vocab.fusepool.info/fam#></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\"><http://www.gsi.dit.upm.es/ontologies/marl/ns#></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\"><http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#></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\"><http://www.gsi.dit.upm.es/ontologies/onyx/ns#></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\"><http://senpy.invalid/></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\"><http://www.w3.org/ns/prov#></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\"><http://www.w3.org/1999/02/22-rdf-syntax-ns#></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\"><http://www.w3.org/2000/01/rdf-schema#></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\"><http://www.gsi.upm.es/onto/senpy/ns#></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\"><http://www.gsi.dit.upm.es/ontologies/wnaffect/ns#></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\"><http://www.w3.org/XML/1998/namespace></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\"><http://www.w3.org/2001/XMLSchema#></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\">"Senpy is awesome"</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\">"marl:Positive"</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_1563372853</span><span class=\"mf\">.6874764</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 awesome}\\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{}1563372853}\\PY{l+m+mf}{.6874764}\\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 awesome\" ;\n",
|
|
" marl:hasOpinion [ a senpy:Sentiment ;\n",
|
|
" marl:hasPolarity \"marl:Positive\" ;\n",
|
|
" prov:wasGeneratedBy prefix:Analysis_1563372853.6874764 ] .\n",
|
|
"\n",
|
|
"[] a senpy:Results ;\n",
|
|
" prov:used prefix: .\n"
|
|
]
|
|
},
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"query(f'{endpoint}/sentiment140',\n",
|
|
" input=\"Senpy is awesome\",\n",
|
|
" outformat=\"turtle\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Moving to a different service"
|
|
]
|
|
},
|
|
{
|
|
"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 modify the earlier example, which uses the `sentiment140` service, to use a different service (e.g. the `sentiment-basic` plugin).\n",
|
|
"We can do it just by changing the URL of the service:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"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\">"@context"</span><span class=\"p\">:</span> <span class=\"s2\">"http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudC1iYXNpYz9pbnB1dD1TZW5weStpcythd2Vzb21lIw%3D%3D"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Results"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"entries"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Entry"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"marl:hasOpinion"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Sentiment"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"marl:hasPolarity"</span><span class=\"p\">:</span> <span class=\"s2\">"marl:Neutral"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"prov:wasGeneratedBy"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:Analysis_1563372853.8034046"</span>\n",
|
|
" <span class=\"p\">}</span>\n",
|
|
" <span class=\"p\">],</span>\n",
|
|
" <span class=\"nt\">"nif:isString"</span><span class=\"p\">:</span> <span class=\"s2\">"Senpy is awesome"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionSet"</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{}1563372853.8034046\\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_1563372853.8034046\"\n",
|
|
" }\n",
|
|
" ],\n",
|
|
" \"nif:isString\": \"Senpy is awesome\",\n",
|
|
" \"onyx:hasEmotionSet\": []\n",
|
|
" }\n",
|
|
" ]\n",
|
|
"}"
|
|
]
|
|
},
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"query(f'{endpoint}/sentiment-basic',\n",
|
|
" input=\"Senpy is awesome\")"
|
|
]
|
|
},
|
|
{
|
|
"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](http://senpy.readthedocs.io/Evaluation.html).\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": 6,
|
|
"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\">"@context"</span><span class=\"p\">:</span> <span class=\"s2\">"http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tZGVwZWNoZW1vb2Q_aW5wdXQ9U2VucHkraXMrYSt3b25kZXJmdWwrdGhhdCtzZXJ2aWNlIw%3D%3D"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Results"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"entries"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Entry"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"marl:hasOpinion"</span><span class=\"p\">:</span> <span class=\"p\">[],</span>\n",
|
|
" <span class=\"nt\">"nif:isString"</span><span class=\"p\">:</span> <span class=\"s2\">"Senpy is a wonderful that service"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionSet"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"EmotionSet"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotion"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionCategory"</span><span class=\"p\">:</span> <span class=\"s2\">"wna:negative-fear"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionIntensity"</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\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionCategory"</span><span class=\"p\">:</span> <span class=\"s2\">"wna:amusement"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionIntensity"</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\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionCategory"</span><span class=\"p\">:</span> <span class=\"s2\">"wna:anger"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionIntensity"</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\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionCategory"</span><span class=\"p\">:</span> <span class=\"s2\">"wna:annoyance"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionIntensity"</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\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionCategory"</span><span class=\"p\">:</span> <span class=\"s2\">"wna:indifference"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionIntensity"</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\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionCategory"</span><span class=\"p\">:</span> <span class=\"s2\">"wna:joy"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionIntensity"</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\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionCategory"</span><span class=\"p\">:</span> <span class=\"s2\">"wna:awe"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionIntensity"</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\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionCategory"</span><span class=\"p\">:</span> <span class=\"s2\">"wna:sadness"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionIntensity"</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\">"prov:wasGeneratedBy"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:Analysis_1563372853.9469151"</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{}1563372853.9469151\\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_1563372853.9469151\"\n",
|
|
" }\n",
|
|
" ]\n",
|
|
" }\n",
|
|
" ]\n",
|
|
"}"
|
|
]
|
|
},
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"query(f'{endpoint}/emotion-depechemood',\n",
|
|
" input=\"Senpy is a wonderful that service\")"
|
|
]
|
|
},
|
|
{
|
|
"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": 7,
|
|
"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\">"@context"</span><span class=\"p\">:</span> <span class=\"s2\">"http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tZGVwZWNoZW1vb2Q_aW5wdXQ9U2VucHkraXMrYSt3b25kZXJmdWwrc2VydmljZSZtYXhlbW90aW9uPVRydWUj"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Results"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"entries"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Entry"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"marl:hasOpinion"</span><span class=\"p\">:</span> <span class=\"p\">[],</span>\n",
|
|
" <span class=\"nt\">"nif:isString"</span><span class=\"p\">:</span> <span class=\"s2\">"Senpy is a wonderful service"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionSet"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"EmotionSet"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotion"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionCategory"</span><span class=\"p\">:</span> <span class=\"s2\">"wna:awe"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionIntensity"</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\">"prov:wasGeneratedBy"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:Analysis_1563372854.0490181"</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{}1563372854.0490181\\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_1563372854.0490181\"\n",
|
|
" }\n",
|
|
" ]\n",
|
|
" }\n",
|
|
" ]\n",
|
|
"}"
|
|
]
|
|
},
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"query(f'{endpoint}/emotion-depechemood',\n",
|
|
" input=\"Senpy is a wonderful service\",\n",
|
|
" maxemotion=True)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Emotion conversion\n",
|
|
"\n",
|
|
"Sometimes the model used by a plugin is not right for your application. Senpy ships with emotion conversion capabilities: you can ask for a specific emotion model in your request and the service will try to automatically convert the results.\n",
|
|
"\n",
|
|
"For example, the `emotion-anew` plugin uses the dimensional `pad` (or VAD, valence-arousal-dominance) model, as we can see here:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"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\">"@context"</span><span class=\"p\">:</span> <span class=\"s2\">"http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tYW5ldz9pbnB1dD1TZW5weStpcythK3dvbmRlcmZ1bCtzZXJ2aWNlK2FuZCtJK2xvdmUraXQj"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Results"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"entries"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Entry"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"marl:hasOpinion"</span><span class=\"p\">:</span> <span class=\"p\">[],</span>\n",
|
|
" <span class=\"nt\">"nif:isString"</span><span class=\"p\">:</span> <span class=\"s2\">"Senpy is a wonderful service and I love it"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionSet"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotions0"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"EmotionSet"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotion"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion0"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal"</span><span class=\"p\">:</span> <span class=\"mf\">6.44</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance"</span><span class=\"p\">:</span> <span class=\"mf\">7.11</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#valence"</span><span class=\"p\">:</span> <span class=\"mf\">8.72</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"prov:wasGeneratedBy"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:Analysis_1563372854.2822595"</span>\n",
|
|
" <span class=\"p\">}</span>\n",
|
|
" <span class=\"p\">],</span>\n",
|
|
" <span class=\"nt\">"prov:wasGeneratedBy"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:Analysis_1563372854.2822595"</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/YXBpL2Vtb3Rpb24tYW5ldz9pbnB1dD1TZW5weStpcythK3dvbmRlcmZ1bCtzZXJ2aWNlK2FuZCtJK2xvdmUraXQj\\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 and I love it\\PYZdq{}}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionSet\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
|
|
" \\PY{p}{\\PYZob{}}\n",
|
|
" \\PY{n+nd}{\\PYZdq{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotions0\\PYZdq{}}\\PY{p}{,}\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{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion0\\PYZdq{}}\\PY{p}{,}\n",
|
|
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns\\PYZsh{}arousal\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{6.44}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns\\PYZsh{}dominance\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{7.11}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns\\PYZsh{}valence\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{8.72}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}prov:wasGeneratedBy\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:Analysis\\PYZus{}1563372854.2822595\\PYZdq{}}\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{}1563372854.2822595\\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/YXBpL2Vtb3Rpb24tYW5ldz9pbnB1dD1TZW5weStpcythK3dvbmRlcmZ1bCtzZXJ2aWNlK2FuZCtJK2xvdmUraXQj\",\n",
|
|
" \"@type\": \"Results\",\n",
|
|
" \"entries\": [\n",
|
|
" {\n",
|
|
" \"@id\": \"prefix:\",\n",
|
|
" \"@type\": \"Entry\",\n",
|
|
" \"marl:hasOpinion\": [],\n",
|
|
" \"nif:isString\": \"Senpy is a wonderful service and I love it\",\n",
|
|
" \"onyx:hasEmotionSet\": [\n",
|
|
" {\n",
|
|
" \"@id\": \"Emotions0\",\n",
|
|
" \"@type\": \"EmotionSet\",\n",
|
|
" \"onyx:hasEmotion\": [\n",
|
|
" {\n",
|
|
" \"@id\": \"Emotion0\",\n",
|
|
" \"@type\": \"Emotion\",\n",
|
|
" \"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal\": 6.44,\n",
|
|
" \"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance\": 7.11,\n",
|
|
" \"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#valence\": 8.72,\n",
|
|
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1563372854.2822595\"\n",
|
|
" }\n",
|
|
" ],\n",
|
|
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1563372854.2822595\"\n",
|
|
" }\n",
|
|
" ]\n",
|
|
" }\n",
|
|
" ]\n",
|
|
"}"
|
|
]
|
|
},
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"query(f'{endpoint}/emotion-anew',\n",
|
|
" input=\"Senpy is a wonderful service and I love it\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"If we need a category level, we can ask for the equivalent results in the `big6` model:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"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\">"@context"</span><span class=\"p\">:</span> <span class=\"s2\">"http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tYW5ldz9pbnB1dD1TZW5weStpcythK3dvbmRlcmZ1bCtzZXJ2aWNlK2FuZCtJK2xvdmUraXQmZW1vdGlvbm1vZGVsPWVtb21sJTNBYmlnNiM%3D"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Results"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"entries"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Entry"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"marl:hasOpinion"</span><span class=\"p\">:</span> <span class=\"p\">[],</span>\n",
|
|
" <span class=\"nt\">"nif:isString"</span><span class=\"p\">:</span> <span class=\"s2\">"Senpy is a wonderful service and I love it"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionSet"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotions0"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"EmotionSet"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotion"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion0"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal"</span><span class=\"p\">:</span> <span class=\"mf\">6.44</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance"</span><span class=\"p\">:</span> <span class=\"mf\">7.11</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#valence"</span><span class=\"p\">:</span> <span class=\"mf\">8.72</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"prov:wasGeneratedBy"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:Analysis_1563372854.3354168"</span>\n",
|
|
" <span class=\"p\">}</span>\n",
|
|
" <span class=\"p\">],</span>\n",
|
|
" <span class=\"nt\">"prov:wasGeneratedBy"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:Analysis_1563372854.3354168"</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/YXBpL2Vtb3Rpb24tYW5ldz9pbnB1dD1TZW5weStpcythK3dvbmRlcmZ1bCtzZXJ2aWNlK2FuZCtJK2xvdmUraXQmZW1vdGlvbm1vZGVsPWVtb21sJTNBYmlnNiM\\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 service and I love it\\PYZdq{}}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionSet\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
|
|
" \\PY{p}{\\PYZob{}}\n",
|
|
" \\PY{n+nd}{\\PYZdq{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotions0\\PYZdq{}}\\PY{p}{,}\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{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion0\\PYZdq{}}\\PY{p}{,}\n",
|
|
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns\\PYZsh{}arousal\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{6.44}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns\\PYZsh{}dominance\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{7.11}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns\\PYZsh{}valence\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{8.72}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}prov:wasGeneratedBy\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:Analysis\\PYZus{}1563372854.3354168\\PYZdq{}}\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{}1563372854.3354168\\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/YXBpL2Vtb3Rpb24tYW5ldz9pbnB1dD1TZW5weStpcythK3dvbmRlcmZ1bCtzZXJ2aWNlK2FuZCtJK2xvdmUraXQmZW1vdGlvbm1vZGVsPWVtb21sJTNBYmlnNiM%3D\",\n",
|
|
" \"@type\": \"Results\",\n",
|
|
" \"entries\": [\n",
|
|
" {\n",
|
|
" \"@id\": \"prefix:\",\n",
|
|
" \"@type\": \"Entry\",\n",
|
|
" \"marl:hasOpinion\": [],\n",
|
|
" \"nif:isString\": \"Senpy is a wonderful service and I love it\",\n",
|
|
" \"onyx:hasEmotionSet\": [\n",
|
|
" {\n",
|
|
" \"@id\": \"Emotions0\",\n",
|
|
" \"@type\": \"EmotionSet\",\n",
|
|
" \"onyx:hasEmotion\": [\n",
|
|
" {\n",
|
|
" \"@id\": \"Emotion0\",\n",
|
|
" \"@type\": \"Emotion\",\n",
|
|
" \"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal\": 6.44,\n",
|
|
" \"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance\": 7.11,\n",
|
|
" \"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#valence\": 8.72,\n",
|
|
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1563372854.3354168\"\n",
|
|
" }\n",
|
|
" ],\n",
|
|
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1563372854.3354168\"\n",
|
|
" }\n",
|
|
" ]\n",
|
|
" }\n",
|
|
" ]\n",
|
|
"}"
|
|
]
|
|
},
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"query(f'{endpoint}/emotion-anew',\n",
|
|
" input=\"Senpy is a wonderful service and I love it\",\n",
|
|
" emotionmodel=\"emoml:big6\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Because we don't usually care about the original emotion, the conversion can be presented in three ways:\n",
|
|
"\n",
|
|
"* full: the original and converted emotions are included at the same level\n",
|
|
"* filtered: the original emotion is replaced by the converted emotion\n",
|
|
"* nested: the original emotion is replaced, but the converted emotion points to it\n",
|
|
"\n",
|
|
"For example, here's how the `nested` structure would look like:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"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\">"@context"</span><span class=\"p\">:</span> <span class=\"s2\">"http://senpy.gsi.upm.es/api/contexts/YXBpL2Vtb3Rpb24tYW5ldz9pbnB1dD1TZW5weStpcythK3dvbmRlcmZ1bCtzZXJ2aWNlK2FuZCtJK2xvdmUraXQmZW1vdGlvbm1vZGVsPWVtb21sJTNBYmlnNiZjb252ZXJzaW9uPW5lc3RlZCM%3D"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Results"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"entries"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Entry"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"marl:hasOpinion"</span><span class=\"p\">:</span> <span class=\"p\">[],</span>\n",
|
|
" <span class=\"nt\">"nif:isString"</span><span class=\"p\">:</span> <span class=\"s2\">"Senpy is a wonderful service and I love it"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotionSet"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotions0"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"EmotionSet"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"onyx:hasEmotion"</span><span class=\"p\">:</span> <span class=\"p\">[</span>\n",
|
|
" <span class=\"p\">{</span>\n",
|
|
" <span class=\"nd\">"@id"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion0"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nd\">"@type"</span><span class=\"p\">:</span> <span class=\"s2\">"Emotion"</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal"</span><span class=\"p\">:</span> <span class=\"mf\">6.44</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance"</span><span class=\"p\">:</span> <span class=\"mf\">7.11</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#valence"</span><span class=\"p\">:</span> <span class=\"mf\">8.72</span><span class=\"p\">,</span>\n",
|
|
" <span class=\"nt\">"prov:wasGeneratedBy"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:Analysis_1563372854.3876536"</span>\n",
|
|
" <span class=\"p\">}</span>\n",
|
|
" <span class=\"p\">],</span>\n",
|
|
" <span class=\"nt\">"prov:wasGeneratedBy"</span><span class=\"p\">:</span> <span class=\"s2\">"prefix:Analysis_1563372854.3876536"</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/YXBpL2Vtb3Rpb24tYW5ldz9pbnB1dD1TZW5weStpcythK3dvbmRlcmZ1bCtzZXJ2aWNlK2FuZCtJK2xvdmUraXQmZW1vdGlvbm1vZGVsPWVtb21sJTNBYmlnNiZjb252ZXJzaW9uPW5lc3RlZCM\\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 service and I love it\\PYZdq{}}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}onyx:hasEmotionSet\\PYZdq{}}\\PY{p}{:} \\PY{p}{[}\n",
|
|
" \\PY{p}{\\PYZob{}}\n",
|
|
" \\PY{n+nd}{\\PYZdq{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotions0\\PYZdq{}}\\PY{p}{,}\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{}@id\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion0\\PYZdq{}}\\PY{p}{,}\n",
|
|
" \\PY{n+nd}{\\PYZdq{}@type\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}Emotion\\PYZdq{}}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns\\PYZsh{}arousal\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{6.44}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns\\PYZsh{}dominance\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{7.11}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns\\PYZsh{}valence\\PYZdq{}}\\PY{p}{:} \\PY{l+m+mf}{8.72}\\PY{p}{,}\n",
|
|
" \\PY{n+nt}{\\PYZdq{}prov:wasGeneratedBy\\PYZdq{}}\\PY{p}{:} \\PY{l+s+s2}{\\PYZdq{}prefix:Analysis\\PYZus{}1563372854.3876536\\PYZdq{}}\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{}1563372854.3876536\\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/YXBpL2Vtb3Rpb24tYW5ldz9pbnB1dD1TZW5weStpcythK3dvbmRlcmZ1bCtzZXJ2aWNlK2FuZCtJK2xvdmUraXQmZW1vdGlvbm1vZGVsPWVtb21sJTNBYmlnNiZjb252ZXJzaW9uPW5lc3RlZCM%3D\",\n",
|
|
" \"@type\": \"Results\",\n",
|
|
" \"entries\": [\n",
|
|
" {\n",
|
|
" \"@id\": \"prefix:\",\n",
|
|
" \"@type\": \"Entry\",\n",
|
|
" \"marl:hasOpinion\": [],\n",
|
|
" \"nif:isString\": \"Senpy is a wonderful service and I love it\",\n",
|
|
" \"onyx:hasEmotionSet\": [\n",
|
|
" {\n",
|
|
" \"@id\": \"Emotions0\",\n",
|
|
" \"@type\": \"EmotionSet\",\n",
|
|
" \"onyx:hasEmotion\": [\n",
|
|
" {\n",
|
|
" \"@id\": \"Emotion0\",\n",
|
|
" \"@type\": \"Emotion\",\n",
|
|
" \"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal\": 6.44,\n",
|
|
" \"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance\": 7.11,\n",
|
|
" \"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/anew/ns#valence\": 8.72,\n",
|
|
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1563372854.3876536\"\n",
|
|
" }\n",
|
|
" ],\n",
|
|
" \"prov:wasGeneratedBy\": \"prefix:Analysis_1563372854.3876536\"\n",
|
|
" }\n",
|
|
" ]\n",
|
|
" }\n",
|
|
" ]\n",
|
|
"}"
|
|
]
|
|
},
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"query(f'{endpoint}/emotion-anew',\n",
|
|
" input=\"Senpy is a wonderful service and I love it\",\n",
|
|
" emotionmodel=\"emoml:big6\",\n",
|
|
" conversion=\"nested\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Learn more\n",
|
|
"\n",
|
|
"[A separate notebook](Advanced.ipynb) covers advanced topics such as listing all plugins available in an endpoint, or creating analysis pipelines that chain several analysis services."
|
|
]
|
|
}
|
|
],
|
|
"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
|
|
}
|