{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Advanced features" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This tutorial takes up where the [basic tutorial](Quickstart.ipynb) left off.\n", "\n", "It covers more advanced tasks such as:\n", "\n", "* Listing available services in an endpoint\n", "* Transforming the results of a service\n", "* Calling multiple services in the same request (Pipelines)\n", "* Running your own Senpy instance" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Requirements" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once again we will use the demo server at http://senpy.gsi.upm.es, and a function to prettify the semantic output." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "endpoint = 'http://senpy.gsi.upm.es/api'" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import requests\n", "from IPython.display import Code\n", " \n", "def query(endpoint, raw=False, **kwargs):\n", " '''Query a given Senpy endpoint with specific parameters, and prettify the output'''\n", " res = requests.get(endpoint,\n", " params=kwargs)\n", " if raw:\n", " return res\n", " return Code(res.text, language=kwargs.get('outformat', 'json-ld'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Selecting fields from the output" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The full output in the previous tutorials is very useful because it is semantically annotated.\n", "However, it is also quite verbose if we only want to label a piece of text, or get a polarity value.\n", "\n", "For such simple cases, the API has a special `fields` method you can use to get a specific field from the results, and even transform the results. Senpy uses jmespath under the hood, which has its own notation.\n", "\n", "To illustrate this, let us get only the text (`nif:isString`) from each entry:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
["Senpy is a wonderful service"]\n",
"
["Senpy is a service. Wonderful service.", "marl:Neutral"]\n",
"
[["Senpy is a wonderful service and I love it"]]\n",
"
{\n",
" "@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MC9lbW90aW9uLWRlcGVjaGVtb29kP2lucHV0PVNlbnB5K2lzK2Erd29uZGVyZnVsK3NlcnZpY2Uj",\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_1563369539.5176148"\n",
" }\n",
" ],\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: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_1563369539.5185866"\n",
" }\n",
" ]\n",
" }\n",
" ]\n",
"}\n",
"
{\n",
" "@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL3NwbGl0L3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcythd2Vzb21lLitBbmQrc2VydmljZXMrYXJlK2NvbXBvc2FibGUuJmRlbGltaXRlcj1zZW50ZW5jZSZsYW5ndWFnZT1lbiZvdXRmb3JtYXQ9anNvbi1sZCM%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_1563369539.7878842"\n",
" }\n",
" ],\n",
" "nif:isString": "Senpy is awesome. And services are composable.",\n",
" "onyx:hasEmotionSet": []\n",
" },\n",
" {\n",
" "@id": "prefix:#char=0,17",\n",
" "@type": "Entry",\n",
" "marl:hasOpinion": [\n",
" {\n",
" "@type": "Sentiment",\n",
" "marl:hasPolarity": "marl:Positive",\n",
" "prov:wasGeneratedBy": "prefix:Analysis_1563369539.7878842"\n",
" }\n",
" ],\n",
" "nif:isString": "Senpy is awesome.",\n",
" "onyx:hasEmotionSet": []\n",
" },\n",
" {\n",
" "@id": "prefix:#char=18,46",\n",
" "@type": "Entry",\n",
" "marl:hasOpinion": [\n",
" {\n",
" "@type": "Sentiment",\n",
" "marl:hasPolarity": "marl:Neutral",\n",
" "prov:wasGeneratedBy": "prefix:Analysis_1563369539.7878842"\n",
" }\n",
" ],\n",
" "nif:isString": "And services are composable.",\n",
" "onyx:hasEmotionSet": []\n",
" }\n",
" ]\n",
"}\n",
"
[["Senpy is awesome. And services are composable.", "marl:Positive"], ["Senpy is awesome.", "marl:Positive"], ["And services are composable.", "marl:Neutral"]]\n",
"
{\n",
" "@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL3BsdWdpbnMvPyM%3D",\n",
" "@type": "Plugins",\n",
" "plugins": [\n",
" {\n",
" "@id": "endpoint:plugins/emotion-anew_0.5.1",\n",
" "@type": "EmotionPlugin",\n",
" "author": "@icorcuera",\n",
" "description": "This plugin consists on an emotion classifier using ANEW lexicon dictionary to calculate VAD (valence-arousal-dominance) of the sentence and determinate which emotion is closer to this value. Each emotion has a centroid, calculated according to this article: http://www.aclweb.org/anthology/W10-0208. The plugin is going to look for the words in the sentence that appear in the ANEW dictionary and calculate the average VAD score for the sentence. Once this score is calculated, it is going to seek the emotion that is closest to this value.",\n",
" "extra_params": {\n",
" "language": {\n",
" "aliases": [\n",
" "language",\n",
" "l"\n",
" ],\n",
" "default": "en",\n",
" "description": "language of the input",\n",
" "options": [\n",
" "es",\n",
" "en"\n",
" ],\n",
" "required": true\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "maxEmotionValue": 1,\n",
" "minEmotionValue": 0,\n",
" "name": "emotion-anew",\n",
" "version": "0.5.1"\n",
" },\n",
" {\n",
" "@id": "endpoint:plugins/emotion-depechemood_0.1",\n",
" "@type": "EmotionPlugin",\n",
" "author": "Oscar Araque",\n",
" "description": "\\nPlugin that uses the DepecheMood emotion lexicon.\\n\\nDepecheMood is an emotion lexicon automatically generated from news articles where users expressed their associated emotions. It contains two languages (English and Italian), as well as three types of word representations (token, lemma and lemma#PoS). For English, the lexicon contains 165k tokens, while the Italian version contains 116k. Unsupervised techniques can be applied to generate simple but effective baselines. To learn more, please visit https://github.com/marcoguerini/DepecheMood and http://www.depechemood.eu/\\n",\n",
" "extra_params": {},\n",
" "is_activated": true,\n",
" "maxEmotionValue": 1,\n",
" "minEmotionValue": 0,\n",
" "name": "emotion-depechemood",\n",
" "version": "0.1"\n",
" },\n",
" {\n",
" "@id": "endpoint:plugins/emotion-wnaffect_0.2",\n",
" "@type": "EmotionPlugin",\n",
" "author": [\n",
" "@icorcuera",\n",
" "@balkian"\n",
" ],\n",
" "description": "\\nEmotion classifier using WordNet-Affect to calculate the percentage\\nof each emotion. This plugin classifies among 6 emotions: anger,fear,disgust,joy,sadness\\nor neutral. The only available language is English (en)\\n",\n",
" "extra_params": {\n",
" "language": {\n",
" "@id": "lang_wnaffect",\n",
" "aliases": [\n",
" "language",\n",
" "l"\n",
" ],\n",
" "description": "language of the input",\n",
" "options": [\n",
" "en"\n",
" ],\n",
" "required": true\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "maxEmotionValue": 1,\n",
" "minEmotionValue": 0,\n",
" "name": "emotion-wnaffect",\n",
" "version": "0.2"\n",
" },\n",
" {\n",
" "@id": "endpoint:plugins/example-plugin_0.1",\n",
" "@type": "Plugin",\n",
" "author": "@balkian",\n",
" "description": "A *VERY* simple plugin that exemplifies the development of Senpy Plugins",\n",
" "extra_params": {\n",
" "parameter": {\n",
" "@id": "parameter",\n",
" "aliases": [\n",
" "parameter",\n",
" "param"\n",
" ],\n",
" "default": 42,\n",
" "description": "this parameter does nothing, it is only an example",\n",
" "required": true\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "name": "example-plugin",\n",
" "version": "0.1"\n",
" },\n",
" {\n",
" "@id": "endpoint:plugins/sentiment-basic_0.1.1",\n",
" "@type": "SentimentPlugin",\n",
" "author": "github.com/nachtkatze",\n",
" "description": "\\nSentiment classifier using rule-based classification for Spanish. Based on english to spanish translation and SentiWordNet sentiment knowledge. This is a demo plugin that uses only some features from the TASS 2015 classifier. To use the entirely functional classifier you can use the service in: http://senpy.gsi.upm.es.\\n",\n",
" "extra_params": {\n",
" "language": {\n",
" "aliases": [\n",
" "language",\n",
" "l"\n",
" ],\n",
" "default": "en",\n",
" "description": "language of the text",\n",
" "options": [\n",
" "en",\n",
" "es",\n",
" "it",\n",
" "fr"\n",
" ],\n",
" "required": true\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "maxPolarityValue": 1,\n",
" "minPolarityValue": -1,\n",
" "name": "sentiment-basic",\n",
" "version": "0.1.1"\n",
" },\n",
" {\n",
" "@id": "endpoint:plugins/sentiment-meaningcloud_1.1",\n",
" "@type": "SentimentPlugin",\n",
" "author": "GSI UPM",\n",
" "description": "\\nSentiment analysis with meaningCloud service.\\nTo use this plugin, you need to obtain an API key from meaningCloud signing up here:\\nhttps://www.meaningcloud.com/developer/login\\n\\nWhen you had obtained the meaningCloud API Key, you have to provide it to the plugin, using param apiKey.\\nExample request:\\n\\nhttp://senpy.gsi.upm.es/api/?algo=meaningCloud&language=en&apiKey=YOUR_API_KEY&input=I%20love%20Madrid.\\n",\n",
" "extra_params": {\n",
" "apikey": {\n",
" "aliases": [\n",
" "apiKey",\n",
" "meaningcloud-key",\n",
" "meaningcloud-apikey"\n",
" ],\n",
" "description": "API key for the meaningcloud service. See https://www.meaningcloud.com/developer/login",\n",
" "required": true\n",
" },\n",
" "language": {\n",
" "aliases": [\n",
" "language",\n",
" "l"\n",
" ],\n",
" "default": "auto",\n",
" "description": "language of the input",\n",
" "options": [\n",
" "en",\n",
" "es",\n",
" "ca",\n",
" "it",\n",
" "pt",\n",
" "fr",\n",
" "auto"\n",
" ],\n",
" "required": true\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "maxPolarityValue": 1,\n",
" "minPolarityValue": -1,\n",
" "name": "sentiment-meaningcloud",\n",
" "version": "1.1"\n",
" },\n",
" {\n",
" "@id": "endpoint:plugins/sentiment-vader_0.1.1",\n",
" "@type": "SentimentPlugin",\n",
" "author": "@icorcuera",\n",
" "description": "\\nSentiment classifier using vaderSentiment module. Params accepted: Language: {en, es}. The output uses Marl ontology developed at GSI UPM for semantic web.\\n",\n",
" "extra_params": {\n",
" "aggregate": {\n",
" "aliases": [\n",
" "aggregate",\n",
" "agg"\n",
" ],\n",
" "default": false,\n",
" "description": "Show only the strongest sentiment (aggregate) or all sentiments",\n",
" "options": [\n",
" true,\n",
" false\n",
" ]\n",
" },\n",
" "language": {\n",
" "@id": "lang_rand",\n",
" "aliases": [\n",
" "language",\n",
" "l"\n",
" ],\n",
" "default": "auto",\n",
" "description": "language of the input",\n",
" "options": [\n",
" "es",\n",
" "en",\n",
" "auto"\n",
" ]\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "maxPolarityValue": 1,\n",
" "minPolarityValue": 0,\n",
" "name": "sentiment-vader",\n",
" "version": "0.1.1"\n",
" },\n",
" {\n",
" "@id": "endpoint:plugins/sentiment140_0.2",\n",
" "@type": "SentimentPlugin",\n",
" "author": "@balkian",\n",
" "description": "Connects to the sentiment140 free API: http://sentiment140.com",\n",
" "extra_params": {\n",
" "language": {\n",
" "@id": "lang_sentiment140",\n",
" "aliases": [\n",
" "language",\n",
" "l"\n",
" ],\n",
" "default": "auto",\n",
" "description": "language of the text",\n",
" "options": [\n",
" "es",\n",
" "en",\n",
" "auto"\n",
" ],\n",
" "required": true\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "maxPolarityValue": 1,\n",
" "minPolarityValue": 0,\n",
" "name": "sentiment140",\n",
" "url": "https://github.com/gsi-upm/senpy-plugins-community",\n",
" "version": "0.2"\n",
" },\n",
" {\n",
" "@id": "endpoint:plugins/split_0.3",\n",
" "@type": "Plugin",\n",
" "author": [\n",
" "@militarpancho",\n",
" "@balkian"\n",
" ],\n",
" "description": "\\nA plugin that chunks input text, into paragraphs or sentences.\\n\\nIt does not provide any sort of annotation, and it is meant to precede\\nother annotation plugins, when the annotation of individual sentences\\n(or paragraphs) is required.\\n",\n",
" "extra_params": {\n",
" "delimiter": {\n",
" "aliases": [\n",
" "type",\n",
" "t"\n",
" ],\n",
" "default": "sentence",\n",
" "description": "Split text into paragraphs or sentences.",\n",
" "options": [\n",
" "sentence",\n",
" "paragraph"\n",
" ],\n",
" "required": false\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "name": "split",\n",
" "url": "https://github.com/gsi-upm/senpy",\n",
" "version": "0.3"\n",
" }\n",
" ]\n",
"}\n",
"
{\n",
" "@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL3BsdWdpbnMvP3BsdWdpbl90eXBlPVNlbnRpbWVudFBsdWdpbiM%3D",\n",
" "@type": "Plugins",\n",
" "plugins": [\n",
" {\n",
" "@id": "endpoint:plugins/sentiment-basic_0.1.1",\n",
" "@type": "SentimentPlugin",\n",
" "author": "github.com/nachtkatze",\n",
" "description": "\\nSentiment classifier using rule-based classification for Spanish. Based on english to spanish translation and SentiWordNet sentiment knowledge. This is a demo plugin that uses only some features from the TASS 2015 classifier. To use the entirely functional classifier you can use the service in: http://senpy.gsi.upm.es.\\n",\n",
" "extra_params": {\n",
" "language": {\n",
" "aliases": [\n",
" "language",\n",
" "l"\n",
" ],\n",
" "default": "en",\n",
" "description": "language of the text",\n",
" "options": [\n",
" "en",\n",
" "es",\n",
" "it",\n",
" "fr"\n",
" ],\n",
" "required": true\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "maxPolarityValue": 1,\n",
" "minPolarityValue": -1,\n",
" "name": "sentiment-basic",\n",
" "version": "0.1.1"\n",
" },\n",
" {\n",
" "@id": "endpoint:plugins/sentiment-meaningcloud_1.1",\n",
" "@type": "SentimentPlugin",\n",
" "author": "GSI UPM",\n",
" "description": "\\nSentiment analysis with meaningCloud service.\\nTo use this plugin, you need to obtain an API key from meaningCloud signing up here:\\nhttps://www.meaningcloud.com/developer/login\\n\\nWhen you had obtained the meaningCloud API Key, you have to provide it to the plugin, using param apiKey.\\nExample request:\\n\\nhttp://senpy.gsi.upm.es/api/?algo=meaningCloud&language=en&apiKey=YOUR_API_KEY&input=I%20love%20Madrid.\\n",\n",
" "extra_params": {\n",
" "apikey": {\n",
" "aliases": [\n",
" "apiKey",\n",
" "meaningcloud-key",\n",
" "meaningcloud-apikey"\n",
" ],\n",
" "description": "API key for the meaningcloud service. See https://www.meaningcloud.com/developer/login",\n",
" "required": true\n",
" },\n",
" "language": {\n",
" "aliases": [\n",
" "language",\n",
" "l"\n",
" ],\n",
" "default": "auto",\n",
" "description": "language of the input",\n",
" "options": [\n",
" "en",\n",
" "es",\n",
" "ca",\n",
" "it",\n",
" "pt",\n",
" "fr",\n",
" "auto"\n",
" ],\n",
" "required": true\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "maxPolarityValue": 1,\n",
" "minPolarityValue": -1,\n",
" "name": "sentiment-meaningcloud",\n",
" "version": "1.1"\n",
" },\n",
" {\n",
" "@id": "endpoint:plugins/sentiment-vader_0.1.1",\n",
" "@type": "SentimentPlugin",\n",
" "author": "@icorcuera",\n",
" "description": "\\nSentiment classifier using vaderSentiment module. Params accepted: Language: {en, es}. The output uses Marl ontology developed at GSI UPM for semantic web.\\n",\n",
" "extra_params": {\n",
" "aggregate": {\n",
" "aliases": [\n",
" "aggregate",\n",
" "agg"\n",
" ],\n",
" "default": false,\n",
" "description": "Show only the strongest sentiment (aggregate) or all sentiments",\n",
" "options": [\n",
" true,\n",
" false\n",
" ]\n",
" },\n",
" "language": {\n",
" "@id": "lang_rand",\n",
" "aliases": [\n",
" "language",\n",
" "l"\n",
" ],\n",
" "default": "auto",\n",
" "description": "language of the input",\n",
" "options": [\n",
" "es",\n",
" "en",\n",
" "auto"\n",
" ]\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "maxPolarityValue": 1,\n",
" "minPolarityValue": 0,\n",
" "name": "sentiment-vader",\n",
" "version": "0.1.1"\n",
" },\n",
" {\n",
" "@id": "endpoint:plugins/sentiment140_0.2",\n",
" "@type": "SentimentPlugin",\n",
" "author": "@balkian",\n",
" "description": "Connects to the sentiment140 free API: http://sentiment140.com",\n",
" "extra_params": {\n",
" "language": {\n",
" "@id": "lang_sentiment140",\n",
" "aliases": [\n",
" "language",\n",
" "l"\n",
" ],\n",
" "default": "auto",\n",
" "description": "language of the text",\n",
" "options": [\n",
" "es",\n",
" "en",\n",
" "auto"\n",
" ],\n",
" "required": true\n",
" }\n",
" },\n",
" "is_activated": true,\n",
" "maxPolarityValue": 1,\n",
" "minPolarityValue": 0,\n",
" "name": "sentiment140",\n",
" "url": "https://github.com/gsi-upm/senpy-plugins-community",\n",
" "version": "0.2"\n",
" }\n",
" ]\n",
"}\n",
"
[["endpoint:plugins/emotion-anew_0.5.1", "EmotionPlugin"], ["endpoint:plugins/emotion-depechemood_0.1", "EmotionPlugin"], ["endpoint:plugins/emotion-wnaffect_0.2", "EmotionPlugin"], ["endpoint:plugins/example-plugin_0.1", "Plugin"], ["endpoint:plugins/sentiment-basic_0.1.1", "SentimentPlugin"], ["endpoint:plugins/sentiment-meaningcloud_1.1", "SentimentPlugin"], ["endpoint:plugins/sentiment-vader_0.1.1", "SentimentPlugin"], ["endpoint:plugins/sentiment140_0.2", "SentimentPlugin"], ["endpoint:plugins/split_0.3", "Plugin"]]\n",
"
{\n",
" "@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL2V2YWx1YXRlLz9hbGdvPXNlbnRpbWVudC12YWRlciZkYXRhc2V0PXZhZGVyJTJDc3RzJm91dGZvcm1hdD1qc29uLWxkIw%3D%3D",\n",
" "@type": "AggregatedEvaluation",\n",
" "senpy:evaluations": [\n",
" {\n",
" "@type": "Evaluation",\n",
" "evaluates": "endpoint:plugins/sentiment-vader_0.1.1__vader",\n",
" "evaluatesOn": "vader",\n",
" "metrics": [\n",
" {\n",
" "@type": "Accuracy",\n",
" "value": 0.6907142857142857\n",
" },\n",
" {\n",
" "@type": "Precision_macro",\n",
" "value": 0.34535714285714286\n",
" },\n",
" {\n",
" "@type": "Recall_macro",\n",
" "value": 0.5\n",
" },\n",
" {\n",
" "@type": "F1_macro",\n",
" "value": 0.40853400929446554\n",
" },\n",
" {\n",
" "@type": "F1_weighted",\n",
" "value": 0.5643605528396403\n",
" },\n",
" {\n",
" "@type": "F1_micro",\n",
" "value": 0.6907142857142857\n",
" },\n",
" {\n",
" "@type": "F1_macro",\n",
" "value": 0.40853400929446554\n",
" }\n",
" ]\n",
" },\n",
" {\n",
" "@type": "Evaluation",\n",
" "evaluates": "endpoint:plugins/sentiment-vader_0.1.1__sts",\n",
" "evaluatesOn": "sts",\n",
" "metrics": [\n",
" {\n",
" "@type": "Accuracy",\n",
" "value": 0.3107177974434612\n",
" },\n",
" {\n",
" "@type": "Precision_macro",\n",
" "value": 0.1553588987217306\n",
" },\n",
" {\n",
" "@type": "Recall_macro",\n",
" "value": 0.5\n",
" },\n",
" {\n",
" "@type": "F1_macro",\n",
" "value": 0.23705926481620407\n",
" },\n",
" {\n",
" "@type": "F1_weighted",\n",
" "value": 0.14731706525451424\n",
" },\n",
" {\n",
" "@type": "F1_micro",\n",
" "value": 0.3107177974434612\n",
" },\n",
" {\n",
" "@type": "F1_macro",\n",
" "value": 0.23705926481620407\n",
" }\n",
" ]\n",
" }\n",
" ]\n",
"}\n",
"
{\n",
" "@context": "http://senpy.gsi.upm.es/api/contexts/YXBpL3NlbnRpbWVudDE0MD9pbnB1dD1TZW5weStpcyt0aGUrYmVzdCtmcmFtZXdvcmsrZm9yK3NlbWFudGljK3NlbnRpbWVudCthbmFseXNpcyUyQythbmQrdmVyeStlYXN5K3RvK3VzZSZ2ZXJib3NlPVRydWUj",\n",
" "@type": "Results",\n",
" "activities": [\n",
" {\n",
" "@id": "prefix:Analysis_1563369541.408701",\n",
" "@type": "Analysis",\n",
" "marl:maxPolarityValue": 1,\n",
" "marl:minPolarityValue": 0,\n",
" "prov:used": [\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "input",\n",
" "value": "Senpy is the best framework for semantic sentiment analysis, and very easy to use"\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "verbose",\n",
" "value": true\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "in-headers",\n",
" "value": false\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "algorithm",\n",
" "value": "default"\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "expanded-jsonld",\n",
" "value": false\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "with-parameters",\n",
" "value": false\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "outformat",\n",
" "value": "json-ld"\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "help",\n",
" "value": false\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "aliases",\n",
" "value": false\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "conversion",\n",
" "value": "full"\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "intype",\n",
" "value": "direct"\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "informat",\n",
" "value": "text"\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "prefix",\n",
" "value": ""\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "urischeme",\n",
" "value": "RFC5147String"\n",
" },\n",
" {\n",
" "@type": "Parameter",\n",
" "name": "language",\n",
" "value": "auto"\n",
" }\n",
" ],\n",
" "prov:wasAssociatedWith": "endpoint:plugins/sentiment140_0.2"\n",
" }\n",
" ],\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_1563369541.408701"\n",
" }\n",
" ],\n",
" "nif:isString": "Senpy is the best framework for semantic sentiment analysis, and very easy to use",\n",
" "onyx:hasEmotionSet": []\n",
" }\n",
" ]\n",
"}\n",
"
{\n",
" "@context": "http://senpy.gsi.upm.es/api/contexts/YXBpLz9oZWxwPVRydWUj",\n",
" "@type": "Help",\n",
" "valid_parameters": {\n",
" "algorithm": {\n",
" "aliases": [\n",
" "algorithms",\n",
" "a",\n",
" "algo"\n",
" ],\n",
" "default": "default",\n",
" "description": "Algorithms that will be used to process the request.It may be a list of comma-separated names.",\n",
" "processor": "string_to_tuple",\n",
" "required": true\n",
" },\n",
" "aliases": {\n",
" "@id": "aliases",\n",
" "aliases": [],\n",
" "default": false,\n",
" "description": "Replace JSON properties with their aliases",\n",
" "options": [\n",
" true,\n",
" false\n",
" ],\n",
" "required": true\n",
" },\n",
" "conversion": {\n",
" "@id": "conversion",\n",
" "default": "full",\n",
" "description": "How to show the elements that have (not) been converted.\\n\\n* full: converted and original elements will appear side-by-side\\n* filtered: only converted elements will be shown\\n* nested: converted elements will be shown, and they will include a link to the original element\\n(using `prov:wasGeneratedBy`).\\n",\n",
" "options": [\n",
" "filtered",\n",
" "nested",\n",
" "full"\n",
" ],\n",
" "required": true\n",
" },\n",
" "emotion-model": {\n",
" "@id": "emotionModel",\n",
" "aliases": [\n",
" "emoModel",\n",
" "emotionModel"\n",
" ],\n",
" "description": "Emotion model to use in the response.\\nSenpy will try to convert the output to this model automatically.\\n\\nExamples: `wna:liking` and `emoml:big6`.\\n ",\n",
" "required": false\n",
" },\n",
" "expanded-jsonld": {\n",
" "@id": "expanded-jsonld",\n",
" "aliases": [\n",
" "expanded",\n",
" "expanded_jsonld"\n",
" ],\n",
" "default": false,\n",
" "description": "use JSON-LD expansion to get full URIs",\n",
" "options": [\n",
" true,\n",
" false\n",
" ],\n",
" "required": true\n",
" },\n",
" "fields": {\n",
" "@id": "fields",\n",
" "description": "A jmespath selector, that can be used to extract a new dictionary, array or value\\nfrom the results.\\njmespath is a powerful query language for json and/or dictionaries.\\nIt allows you to change the structure (and data) of your objects through queries.\\n\\ne.g., the following expression gets a list of `[emotion label, intensity]` for each entry:\\n`entries[].\\"onyx:hasEmotionSet\\"[].\\"onyx:hasEmotion\\"[][\\"onyx:hasEmotionCategory\\",\\"onyx:hasEmotionIntensity\\"]`\\n\\nFor more information, see: https://jmespath.org\\n\\n",\n",
" "required": false\n",
" },\n",
" "help": {\n",
" "@id": "help",\n",
" "aliases": [\n",
" "h"\n",
" ],\n",
" "default": false,\n",
" "description": "Show additional help to know more about the possible parameters",\n",
" "options": [\n",
" true,\n",
" false\n",
" ],\n",
" "required": true\n",
" },\n",
" "in-headers": {\n",
" "aliases": [\n",
" "headers",\n",
" "inheaders",\n",
" "inHeaders",\n",
" "in-headers",\n",
" "in_headers"\n",
" ],\n",
" "default": false,\n",
" "description": "Only include the JSON-LD context in the headers",\n",
" "options": [\n",
" true,\n",
" false\n",
" ],\n",
" "required": true\n",
" },\n",
" "informat": {\n",
" "@id": "informat",\n",
" "aliases": [\n",
" "f"\n",
" ],\n",
" "default": "text",\n",
" "description": "input format",\n",
" "options": [\n",
" "text",\n",
" "json-ld"\n",
" ],\n",
" "required": false\n",
" },\n",
" "input": {\n",
" "@id": "input",\n",
" "aliases": [\n",
" "i"\n",
" ],\n",
" "help": "Input text",\n",
" "required": true\n",
" },\n",
" "intype": {\n",
" "@id": "intype",\n",
" "aliases": [\n",
" "t"\n",
" ],\n",
" "default": "direct",\n",
" "description": "input type",\n",
" "options": [\n",
" "direct",\n",
" "url",\n",
" "file"\n",
" ],\n",
" "required": false\n",
" },\n",
" "language": {\n",
" "aliases": [\n",
" "language",\n",
" "l"\n",
" ],\n",
" "default": "en",\n",
" "description": "language of the input",\n",
" "options": [\n",
" "es",\n",
" "en"\n",
" ],\n",
" "required": true\n",
" },\n",
" "outformat": {\n",
" "@id": "outformat",\n",
" "aliases": [\n",
" "o"\n",
" ],\n",
" "default": "json-ld",\n",
" "description": "The data can be semantically formatted (JSON-LD, turtle or n-triples),\\ngiven as a list of comma-separated fields (see the fields option) or constructed from a Jinja2\\ntemplate (see the template option).",\n",
" "options": [\n",
" "json-ld",\n",
" "turtle",\n",
" "ntriples"\n",
" ],\n",
" "required": true\n",
" },\n",
" "prefix": {\n",
" "@id": "prefix",\n",
" "aliases": [\n",
" "p"\n",
" ],\n",
" "default": "",\n",
" "description": "prefix to use for new entities",\n",
" "required": true\n",
" },\n",
" "template": {\n",
" "@id": "template",\n",
" "description": "Jinja2 template for the result. The input data for the template will\\nbe the results as a dictionary.\\nFor example:\\n\\nConsider the results before templating:\\n\\n```\\n[{\\n \\"@type\\": \\"entry\\",\\n \\"onyx:hasEmotionSet\\": [],\\n \\"nif:isString\\": \\"testing the template\\",\\n \\"marl:hasOpinion\\": [\\n {\\n \\"@type\\": \\"sentiment\\",\\n \\"marl:hasPolarity\\": \\"marl:Positive\\"\\n }\\n ]\\n}]\\n```\\n\\n\\nAnd the template:\\n\\n```\\n{% for entry in entries %}\\n{{ entry[\\"nif:isString\\"] | upper }},{{entry.sentiments[0][\\"marl:hasPolarity\\"].split(\\":\\")[1]}}\\n{% endfor %}\\n```\\n\\nThe final result would be:\\n\\n```\\nTESTING THE TEMPLATE,Positive\\n```\\n",\n",
" "required": false\n",
" },\n",
" "urischeme": {\n",
" "@id": "urischeme",\n",
" "aliases": [\n",
" "u"\n",
" ],\n",
" "default": "RFC5147String",\n",
" "description": "scheme for NIF URIs",\n",
" "options": [\n",
" "RFC5147String"\n",
" ],\n",
" "required": false\n",
" },\n",
" "verbose": {\n",
" "@id": "verbose",\n",
" "aliases": [\n",
" "v"\n",
" ],\n",
" "default": false,\n",
" "description": "Show all properties in the result",\n",
" "options": [\n",
" true,\n",
" false\n",
" ],\n",
" "required": true\n",
" },\n",
" "with-parameters": {\n",
" "aliases": [\n",
" "withparameters",\n",
" "with_parameters"\n",
" ],\n",
" "default": false,\n",
" "description": "include initial parameters in the response",\n",
" "options": [\n",
" true,\n",
" false\n",
" ],\n",
" "required": true\n",
" }\n",
" }\n",
"}\n",
"
{\n",
" "@type": "Results",\n",
" "entries": [\n",
" {\n",
" "@id": "prefix:",\n",
" "@type": "Entry",\n",
" "marl:hasOpinion": [],\n",
" "nif:isString": "This will tell senpy to only include the context in the headers",\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": 4.22,\n",
" "http://www.gsi.upm.es/ontologies/onyx/vocabularies/anew/ns#dominance": 5.17,\n",
" "http://www.gsi.upm.es/ontologies/onyx/vocabularies/anew/ns#valence": 5.2,\n",
" "prov:wasGeneratedBy": "prefix:Analysis_1563369541.631805"\n",
" }\n",
" ],\n",
" "prov:wasGeneratedBy": "prefix:Analysis_1563369541.631805"\n",
" }\n",
" ]\n",
" }\n",
" ]\n",
"}\n",
"