.\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": [
"{\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",
"}\n",
"
\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": [
"{\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",
"}\n",
"
\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": [
"{\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",
"}\n",
"
\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": [
"{\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.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal": 6.44,\n",
" "http://www.gsi.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance": 7.11,\n",
" "http://www.gsi.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",
"}\n",
"
\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.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.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.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.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal\": 6.44,\n",
" \"http://www.gsi.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance\": 7.11,\n",
" \"http://www.gsi.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": [
"{\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.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal": 6.44,\n",
" "http://www.gsi.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance": 7.11,\n",
" "http://www.gsi.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",
"}\n",
"
\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.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.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.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.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal\": 6.44,\n",
" \"http://www.gsi.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance\": 7.11,\n",
" \"http://www.gsi.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": [
"{\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.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal": 6.44,\n",
" "http://www.gsi.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance": 7.11,\n",
" "http://www.gsi.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",
"}\n",
"
\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.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.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.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.upm.es/ontologies/onyx/vocabularies/anew/ns#arousal\": 6.44,\n",
" \"http://www.gsi.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance\": 7.11,\n",
" \"http://www.gsi.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
}