1
0
mirror of https://github.com/balkian/gists.git synced 2024-11-01 08:01:44 +00:00
gists/migueljsonld.ipynb

120 lines
124 KiB
Plaintext
Raw Normal View History

2014-04-02 19:27:49 +00:00
{
"metadata": {
"name": "Untitled0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
2014-04-02 19:44:48 +00:00
"source": "Instalar\n========\nS\u00f3lo hace falta instalar pyld: https://github.com/digitalbazaar/pyld\n\n```bash\npip install pyld \n```\n\nTambi\u00e9n puedes instalar rdflib para convertir el fichero de xml-rdf a nt.\n\nModificar el frame\n==================\nLo que metas dentro del frame se usa para dos cosas:\n * La parte del contexto se usa para compactizar (reducir nombres, son los prefijos)\n * El total se usa para dar estructura al json final\n \nPor tanto, aqu\u00ed puedes decirle qu\u00e9 espacios de nombres y qu\u00e9 campos usar.\nComo ver\u00e1s, adem\u00e1s de hacer framing hago compact.\n\u00bfPor qu\u00e9?, pues porque el framing deja una lista de objetos colgando de \"@graph\", y si esa lista tiene un s\u00f3lo elemento podemos pasar esos atributos a la \"ra\u00edz\" para hacer m\u00e1s legible el json.\n\nPor ejemplo:\n```json\n{ ...\n \"@graph\": [ {\"@id\": \"test\", \"name\": \"testing\"}]\n}\n```\n\nSe convierte en:\n\n```json\n{ ...\n \"@id\": \"test\",\n \"name\": \"testing\"\n\n}\n```\n\nEn el caso de los channels, el frame contendr\u00e1 '\"@type\": \"ewe:Channel\"'; en las reglas '\"@type\": \"ewe:Rule\"'. El contexto no deber\u00eda cambiar.\n\n\nSin l\u00edos\n========\n\nPuedes usar el json-ld playground para estas cosas: [Enlace](http://json-ld.org/playground/index.html#startTab=tab-framed&json-ld=%7B%22%40context%22%3A%7B%22foaf%22%3A%22http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%22%2C%22owl%22%3A%22http%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23%22%2C%22rdfs%22%3A%22http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%22%2C%22image%22%3A%7B%22%40id%22%3A%22http%3A%2F%2Fschema.org%2Fimage%22%2C%22%40type%22%3A%22%40id%22%7D%2C%22tags%22%3A%22http%3A%2F%2Fwww.holygoat.co.uk%2Fowl%2Fredwood%2F0.1%2Ftags%2F%22%2C%22ewe%22%3A%22http%3A%2F%2Fgsi.dit.upm.es%2Fontologies%2Fewe%2Fns%2F%22%2C%22rdf%22%3A%22http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%22%2C%22xsd%22%3A%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%22%2C%22dcterms%22%3A%22http%3A%2F%2Fpurl.org%2Fdc%2Fterms%2F%22%2C%22homepage%22%3A%7B%22%40id%22%3A%22http%3A%2F%2Fschema.org%2Furl%22%2C%22%40type%22%3A%22%40id%22%7D%2C%22spinrdf%22%3A%22http%3A%2F%2Fspinrdf.org%2Fsp%23%22%7D%2C%22%40graph%22%3A%5B%7B%22%40id%22%3A%22_%3Ab0%22%2C%22spinrdf%3AvarName%22%3A%22message%22%7D%2C%7B%22%40id%22%3A%22_%3Ab1%22%2C%22spinrdf%3AvarName%22%3A%22action%22%7D%2C%7B%22spinrdf%3Atemplates%22%3A%7B%22%40list%22%3A%5B%7B%22spinrdf%3Apredicate%22%3A%7B%22%40id%22%3A%22rdf%3Atype%22%7D%2C%22spinrdf%3Aobject%22%3A%7B%22%40id%22%3A%22http%3A%2F%2Fgsi.dit.upm.es%2Fontologies%2Fewe%23Action%22%7D%2C%22%40id%22%3A%22_%3Ab11%22%2C%22spinrdf%3Asubject%22%3A%7B%22%40id%22%3A%22_%3Ab38%22%2C%22spinrdf%3AvarName%22%3A%22action%22%7D%7D%2C%7B%22spinrdf%3Apredicate%22%3A%7B%22%40id%22%3A%22dcterms%3Atitle%22%7D%2C%22spinrdf%3Aobject%22%3A%22New%20chat%20message%22%2C%22%40id%22%3A%22_%3Ab12%22%2C%22spinrdf%3Asubject%22%3A%7B%22%40id%22%3A%22_%3Ab23%22%2C%22spinrdf%3AvarName%22%3A%22action%22%7D%7D%2C%7B%22spinrdf%3Apredicate%22%3A%7B%22%40id%22%3A%22http%3A%2F%2Fgsi.dit.upm.es%2Fontologies%2Fewe%23hasParameter%22%7D%2C%22spinrdf%3Aobject%22%3A%7B%22%40id%22%3A%22_%3Ab37%22%2C%22spinrdf%3AvarName%22%3A%22iParam%22%7D%2C%22%40id%22%3A%22_%3Ab13%22%2C%22spinrdf%3Asubject%22%3A%7B%22%40id%22%3A%22_%3Ab32%22%2C%22spinrdf%3AvarName%22%3A%22action%22%7D%7D%2C%7B%22spinrdf%3Apredicate%22%3A%7B%22%40id%22%3A%22dcterms%3Atitle%22%7D%2C%22spinrdf%3Aobject%22%3A%22message%22%2C%22%40id%22%3A%22_%3Ab7%22%2C%22spinrdf%3Asubject%22%3A%7B%22%40id%22%3A%22_%3Ab8%22%2C%22spinrdf%3AvarName%22%3A%22iParam%22%7D%7D%2C%7B%22spinrdf%3Apredicate%22%3A%7B%22%40id%22%3A%22dcterms%3Avalue%22%7D%2C%22spinrdf%3Aobject%22%3A%7B%22%40id%22%3A%22_%3Ab0%22%2C%22spinrdf%3AvarName%22%3A%22message%22%7D%2C%22%40id%22%3A%22_%3Ab2%22%2C%22spinrdf%3Asubject%22%3A%7B%22%40id%22%3A%22_%3Ab3%22%2C%22spinrdf%3AvarName%22%3A%22iParam%22%7D%7D%2C%7B%22spinrdf%3Apredicate%22%3A%7B%22%40id%22%3A%22http%3A%2F%2Fgsi.dit.upm.es%2Fontologies%2Fewe%23providesAction%22%7D%2C%22spinrdf%3Aobject%22%3
2014-04-02 19:27:49 +00:00
},
{
"cell_type": "code",
"collapsed": false,
2014-04-02 19:38:31 +00:00
"input": "from rdflib import Graph\ng = Graph()",
2014-04-02 19:27:49 +00:00
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
2014-04-02 19:38:31 +00:00
{
"cell_type": "code",
"collapsed": true,
"input": " # rdf = open('example.rdf', 'r')\n from StringIO import StringIO\n rdf = StringIO('''<?xml version=\"1.0\" encoding=\"utf-8\"?>\n \n <rdf:RDF \n xmlns:foaf=\"http://xmlns.com/foaf/0.1/\" \n xmlns:owl=\"http://www.w3.org/2002/07/owl#\" \n xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" \n xmlns:ewe=\"http://gsi.dit.upm.es/ontologies/ewe/ns/\" \n xmlns:xsd=\"http://www.w3.org/2001/XMLSchema#\" \n xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" \n xmlns:dcterms=\"http://purl.org/dc/terms/\" \n xmlns:tags=\"http://www.holygoat.co.uk/owl/redwood/0.1/tags/\" \n xmlns=\"http://gsi.dit.upm.es/ontologies/ewe/ns/\">\n \n <!-- Channel Instance Description -->\n <ewe:Channel rdf:about=\"https://ifttt.com/gmail\">\n <dcterms:title>Gmail</dcterms:title>\n <dcterms:description>Googles approach to email, Gmail, is built on the idea that email can be moreintuitive, efficient, and useful. And maybe even fun.</dcterms:description>\n <foaf:url>http://gmail.com</foaf:url>\n <foaf:logo>https://ifttt.com/images/channels/gmail_lrg.png</foaf:logo>\n <!-- Event and action references -->\n <ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/87\" />\n <ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/85\" />\n <ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/186\" />\n <ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/86\" />\n <ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/367\" />\n <ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/185\" /> \n <ewe:providesAction rdf:resource=\"https://ifttt.com/channels/gmail/actions/34\" />\n </ewe:Channel>\n \n <!-- Event Instances -->\n <ewe:Event rdf:about=\"https://ifttt.com/channels/gmail/triggers/87\">\n <dcterms:title>New email from search</dcterms:title> \n <dcterms:description>This Trigger fires every time a new email arrives in your inbox that matchesthe search query you specify.</dcterms:description> \n <ewe:hasOutputParameter>\n <ewe:outputParameter>\n <dcterms:title>FromAddress</dcterms:title> \n <dcterms:description>Email address of sender.</dcterms:description> \n <ewe:example>somebody@gmail.com</ewe:example> \n </ewe:outputParameter>\n </ewe:hasOutputParameter>\n <ewe:hasOutputParameter>\n <ewe:outputParameter>\n <dcterms:title>Subject</dcterms:title> \n <dcterms:description>Email subject line.</dcterms:description> \n <ewe:example>Hello there</ewe:example> \n </ewe:outputParameter>\n </ewe:hasOutputParameter>\n <ewe:hasOutputParameter>\n <ewe:outputParameter>\n <dcterms:title>BodyPlain</dcterms:title> \n <dcterms:description>Plain text email body.</dcterms:description> \n <ewe:example>Been having a good day so far...</ewe:example> \n </ewe:outputParameter>\n </ewe:hasOutputParameter>\n <ewe:hasOutputParameter>\n <ewe:outputParameter>\n <dcterms:title>FirstAttachmentPrivateURL</dcterms:title> \n <dcterms:description>A URL to the first file attachment (if any) that only you can see.</dcterms:description> \n <ewe:example>https://locker.ifttt.com/f/29b08556-ac73-11e2-a707-22000a9730cf</ewe:example> \n </ewe:outputParameter>\n </ewe:hasOutputParameter>\n <ewe:hasOutputParameter>\n <ewe:outputParameter>\n <dcterms:title>FirstAttachmentPublicURL</dcterms:title> \n
"language": "python",
"metadata": {},
"outputs": [],
2014-04-02 19:44:48 +00:00
"prompt_number": 2
2014-04-02 19:38:31 +00:00
},
{
"cell_type": "code",
"collapsed": false,
2014-04-02 19:44:48 +00:00
"input": "rdf = StringIO('''<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<rdf:RDF \n\txmlns:foaf=\"http://xmlns.com/foaf/0.1/\" \n\txmlns:owl=\"http://www.w3.org/2002/07/owl#\" \n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" \n\txmlns:ewe=\"http://gsi.dit.upm.es/ontologies/ewe/ns/\" \n\txmlns:xsd=\"http://www.w3.org/2001/XMLSchema#\" \n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" \n\txmlns:dcterms=\"http://purl.org/dc/terms/\" \n\txmlns:tags=\"http://www.holygoat.co.uk/owl/redwood/0.1/tags/\" \n\txmlns=\"http://gsi.dit.upm.es/ontologies/ewe/ns/\">\n\n\t<!-- Channel Instance Description -->\n\t<ewe:Channel rdf:about=\"https://ifttt.com/gmail\">\n\t\t<dcterms:title>Gmail</dcterms:title>\n\t\t<dcterms:description>Googles approach to email, Gmail, is built on the idea that email can be moreintuitive, efficient, and useful. And maybe even fun.</dcterms:description>\n\t\t<foaf:url>http://gmail.com</foaf:url>\n\t\t<foaf:logo>https://ifttt.com/images/channels/gmail_lrg.png</foaf:logo>\n\t\t<!-- Event and action references -->\n\t\t<ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/87\" />\n\t\t<ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/85\" />\n\t\t<ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/186\" />\n\t\t<ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/86\" />\n\t\t<ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/367\" />\n\t\t<ewe:generatesEvent rdf:resource=\"https://ifttt.com/channels/gmail/triggers/185\" /> \n\t\t<ewe:providesAction rdf:resource=\"https://ifttt.com/channels/gmail/actions/34\" />\n\t</ewe:Channel>\n\n\t<!-- Event Instances -->\n\t<ewe:Event rdf:about=\"https://ifttt.com/channels/gmail/triggers/87\">\n\t <dcterms:title>New email from search</dcterms:title> \n \t<dcterms:description>This Trigger fires every time a new email arrives in your inbox that matchesthe search query you specify.</dcterms:description> \n\t <ewe:hasOutputParameter>\n \t <ewe:outputParameter>\n\t \t<dcterms:title>FromAddress</dcterms:title> \n\t \t <dcterms:description>Email address of sender.</dcterms:description> \n\t\t <ewe:example>somebody@gmail.com</ewe:example> \n \t </ewe:outputParameter>\n\t </ewe:hasOutputParameter>\n\t <ewe:hasOutputParameter>\n\t\t <ewe:outputParameter>\n\t\t <dcterms:title>Subject</dcterms:title> \n\t\t <dcterms:description>Email subject line.</dcterms:description> \n\t\t <ewe:example>Hello there</ewe:example> \n\t\t </ewe:outputParameter>\n\t </ewe:hasOutputParameter>\n\t\t<ewe:hasOutputParameter>\n \t <ewe:outputParameter>\n\t\t <dcterms:title>BodyPlain</dcterms:title> \n\t\t <dcterms:description>Plain text email body.</dcterms:description> \n\t\t <ewe:example>Been having a good day so far...</ewe:example> \n \t </ewe:outputParameter>\n\t </ewe:hasOutputParameter>\n\t <ewe:hasOutputParameter>\n \t <ewe:outputParameter>\n\t\t\t\t<dcterms:title>FirstAttachmentPrivateURL</dcterms:title> \n\t\t\t\t<dcterms:description>A URL to the first file attachment (if any) that only you can see.</dcterms:description> \n\t\t\t\t<ewe:example>https://locker.ifttt.com/f/29b08556-ac73-11e2-a707-22000a9730cf</ewe:example> \n \t </ewe:outputParameter>\n\t </ewe:hasOutputParameter>\n \t<ewe:hasOutputParameter>\n \t <ewe:outputParameter>\n\t\t\t\t<dcterms:title>FirstAttachmentPublicURL</dcterms:title> \n\t\t\t\t<dcterms:description>A URL to the first file attachment (if any) that anyone can see.</dcterms:description> \n\t\t\t\t<ewe:example>https://locker.ifttt.com/f/4bfc930c-ac73-11e2-b086-22000a9730cf</ewe:example> \n \t </ewe:outputParameter>\n\t\t</ewe:hasOutputParameter>\n\t\t<ewe:hasOutputParameter>\n \t <ewe:outputParameter>\n\t\t\t\t<dcterms:title>FirstAttachmentFilename</dcterms:title> \n\t\t\t\t<dcterms:description>The filename of the first file attachment (if any).</dcterms:description> \n\t
2014-04-02 19:38:31 +00:00
"language": "python",
"metadata": {},
"outputs": [],
2014-04-02 19:44:48 +00:00
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": "g.parse(rdf)\nnt = g.serialize(format='nt')\nnt",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 4,
"text": "'_:N902dc61e92d24ac4b8c7d0e9dfa444b9 <http://purl.org/dc/terms/title> \"Subject\" .\\n_:N0dd4c4ac84064309b41dcf1e7fe3918c <http://purl.org/dc/terms/title> \"FirstAttachmentPrivateURL\" .\\n<https://ifttt.com/channels/gmail/actions/34> <http://purl.org/dc/terms/title> \"Send an email\" .\\n_:N615b6ec4c6bd434ca92ac7314fd27f19 <http://purl.org/dc/terms/title> \"ReceivedAt\" .\\n_:Nf4fc972a2dad4c4bb88dc7a7a80280a3 <http://gsi.dit.upm.es/ontologies/ewe/ns/example> \"somebody@gmail.com\" .\\n_:N615b6ec4c6bd434ca92ac7314fd27f19 <http://purl.org/dc/terms/description> \"Date and time email was received.\" .\\n_:N0210346037ba4ac2bdc1155a9ef60c63 <http://purl.org/dc/terms/description> \"The filename of the first file attachment (if any).\" .\\n<https://ifttt.com/channels/gmail/triggers/186> <http://gsi.dit.upm.es/ontologies/ewe/ns/hasOutputParameter> _:N6ebd190ec7554496aa6b24d1fae9e33a .\\n_:N902dc61e92d24ac4b8c7d0e9dfa444b9 <http://gsi.dit.upm.es/ontologies/ewe/ns/example> \"Hello there\" .\\n_:N9448220723f74fbd98e67f1880de1ced <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gsi.dit.upm.es/ontologies/ewe/ns/outputParameter> .\\n_:Nec46842ec98a4ac08437c492563b0bb9 <http://purl.org/dc/terms/description> \"Date and time email was received.\" .\\n_:Neb3f393873c247ed8d4b70731dc7bbcf <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gsi.dit.upm.es/ontologies/ewe/ns/outputParameter> .\\n<https://ifttt.com/channels/gmail/triggers/186> <http://gsi.dit.upm.es/ontologies/ewe/ns/hasOutputParameter> _:N8fa2723166854100bb95cadcbe808e2d .\\n_:N401f62004d1142fb9f1eb85694c32c32 <http://purl.org/dc/terms/title> \"ReceivedAt\" .\\n<https://ifttt.com/gmail> <http://gsi.dit.upm.es/ontologies/ewe/ns/generatesEvent> <https://ifttt.com/channels/gmail/triggers/85> .\\n<https://ifttt.com/channels/gmail/triggers/185> <http://gsi.dit.upm.es/ontologies/ewe/ns/hasOutputParameter> _:N6fbae96ee43a4e8aa5b4e1e968719dec .\\n<https://ifttt.com/channels/gmail/triggers/87> <http://gsi.dit.upm.es/ontologies/ewe/ns/hasOutputParameter> _:N178bffdecedc4013ba4ae1ed4cefd0f0 .\\n_:Nb2bf44e27916498e9eddf9a486ee8dc7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gsi.dit.upm.es/ontologies/ewe/ns/outputParameter> .\\n<https://ifttt.com/channels/gmail/triggers/87> <http://gsi.dit.upm.es/ontologies/ewe/ns/hasOutputParameter> _:N76df4cf31348496e8a394c137d0200f8 .\\n<https://ifttt.com/channels/gmail/triggers/186> <http://gsi.dit.upm.es/ontologies/ewe/ns/hasOutputParameter> _:N9448220723f74fbd98e67f1880de1ced .\\n_:Nf3422c781f97402291ba9dec3e5bed06 <http://gsi.dit.upm.es/ontologies/ewe/ns/example> \"https://locker.ifttt.com/f/4bfc930c-ac73-11e2-b086-22000a9730cf\" .\\n_:N1c63fdb0196a44c19ea23f031c6e1571 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gsi.dit.upm.es/ontologies/ewe/ns/outputParameter> .\\n_:N8fa2723166854100bb95cadcbe808e2d <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gsi.dit.upm.es/ontologies/ewe/ns/outputParameter> .\\n<https://ifttt.com/channels/gmail/triggers/85> <http://gsi.dit.upm.es/ontologies/ewe/ns/hasOutputParameter> _:Nb2bf44e27916498e9eddf9a486ee8dc7 .\\n_:N76df4cf31348496e8a394c137d0200f8 <http://purl.org/dc/terms/description> \"The filename of the first file attachment (if any).\" .\\n_:N6fbae96ee43a4e8aa5b4e1e968719dec <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gsi.dit.upm.es/ontologies/ewe/ns/outputParameter> .\\n_:N0d990526ca5349af9bc84d189e57ebe2 <http://gsi.dit.upm.es/ontologies/ewe/ns/example> \"Been having a good day so far...\" .\\n_:Na387f99b32994cfcbe029c0d3dc7a9c7 <http://purl.org/dc/terms/description> \"Date and time email was received.\" .\\n<https://ifttt.com/channels/gmail/triggers/367> <http://gsi.dit.upm.es/ontologies/ewe/ns/hasOutputParameter> _:N238780b0d04b408187ff5e9dbbb35849 .\\n_:N2a4af8059cd54651a33f77bc82fcabf6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gsi.dit.upm.es/ontologies/ewe/ns/outputParameter> .\\n_:Nee0e3d565db5471c9efd5248f8aa66b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gsi.dit.upm.es/ontologies/ewe/ns/ou
}
],
"prompt_number": 4
2014-04-02 19:38:31 +00:00
},
2014-04-02 19:27:49 +00:00
{
"cell_type": "code",
"collapsed": false,
"input": "#nt = open('example.nt','r').read()",
"language": "python",
"metadata": {},
"outputs": [],
2014-04-02 19:44:48 +00:00
"prompt_number": 5
2014-04-02 19:27:49 +00:00
},
{
"cell_type": "code",
"collapsed": false,
"input": "from pyld import jsonld\nimport json",
"language": "python",
"metadata": {},
"outputs": [],
2014-04-02 19:44:48 +00:00
"prompt_number": 6
2014-04-02 19:27:49 +00:00
},
{
"cell_type": "code",
"collapsed": false,
2014-04-02 19:38:31 +00:00
"input": "j = jsonld.from_rdf(nt)",
2014-04-02 19:27:49 +00:00
"language": "python",
"metadata": {},
"outputs": [],
2014-04-02 19:44:48 +00:00
"prompt_number": 7
2014-04-02 19:27:49 +00:00
},
{
"cell_type": "code",
"collapsed": false,
2014-04-02 19:44:48 +00:00
"input": "frame = {\n \"@context\": {\n \"foaf\": \"http://xmlns.com/foaf/0.1/\",\n \"owl\": \"http://www.w3.org/2002/07/owl#\",\n \"rdf\": \"http://www.w3.org/1999/02/22-rdf-syntax-ns#\",\n \"ewe\": \"http://gsi.dit.upm.es/ontologies/ewe/ns/\",\n \"xsd\": \"http://www.w3.org/2001/XMLSchema#\",\n \"rdfs\": \"http://www.w3.org/2000/01/rdf-schema#\",\n \"dcterms\": \"http://purl.org/dc/terms/\",\n \"tags\": \"http://www.holygoat.co.uk/owl/redwood/0.1/tags/\",\n \"spinrdf\": \"http://spinrdf.org/sp#\",\n \"homepage\": {\n \"@id\": \"http://schema.org/url\",\n \"@type\": \"@id\"\n },\n \"image\": {\n \"@id\": \"http://schema.org/image\",\n \"@type\": \"@id\"\n }\n },\n \"@type\": \"ewe:Channel\"\n}\nugly = jsonld.frame(j, frame)\nprint json.dumps(jsonld.compact(ugly, frame), indent=4, sort_keys=True)",
2014-04-02 19:27:49 +00:00
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
2014-04-02 19:44:48 +00:00
"text": "{\n \"@context\": {\n \"dcterms\": \"http://purl.org/dc/terms/\", \n \"ewe\": \"http://gsi.dit.upm.es/ontologies/ewe/ns/\", \n \"foaf\": \"http://xmlns.com/foaf/0.1/\", \n \"homepage\": {\n \"@id\": \"http://schema.org/url\", \n \"@type\": \"@id\"\n }, \n \"image\": {\n \"@id\": \"http://schema.org/image\", \n \"@type\": \"@id\"\n }, \n \"owl\": \"http://www.w3.org/2002/07/owl#\", \n \"rdf\": \"http://www.w3.org/1999/02/22-rdf-syntax-ns#\", \n \"rdfs\": \"http://www.w3.org/2000/01/rdf-schema#\", \n \"spinrdf\": \"http://spinrdf.org/sp#\", \n \"tags\": \"http://www.holygoat.co.uk/owl/redwood/0.1/tags/\", \n \"xsd\": \"http://www.w3.org/2001/XMLSchema#\"\n }, \n \"@id\": \"https://ifttt.com/gmail\", \n \"@type\": \"ewe:Channel\", \n \"dcterms:description\": \"Googles approach to email, Gmail, is built on the idea that email can be moreintuitive, efficient, and useful. And maybe even fun.\", \n \"dcterms:title\": \"Gmail\", \n \"ewe:generatesEvent\": [\n {\n \"@id\": \"https://ifttt.com/channels/gmail/triggers/85\", \n \"@type\": \"ewe:Event\", \n \"dcterms:description\": \"This Trigger fires every time a new email arrives in your inbox with the labelyou specify.\", \n \"dcterms:title\": \"New email labeled\", \n \"ewe:hasInputParameter\": {\n \"@id\": \"_:b34\", \n \"@type\": \"ewe:InputParameter\", \n \"dcterms:title\": \"Label\", \n \"xsd:type\": \"string_value\"\n }, \n \"ewe:hasOutputParameter\": [\n {\n \"@id\": \"_:b38\", \n \"@type\": \"ewe:outputParameter\", \n \"dcterms:description\": \"A URL to the first file attachment (if any) that anyone can see.\", \n \"dcterms:title\": \"FirstAttachmentPublicURL\", \n \"ewe:example\": \"https://locker.ifttt.com/f/4bfc930c-ac73-11e2-b086-22000a9730cf\"\n }, \n {\n \"@id\": \"_:b48\", \n \"@type\": \"ewe:outputParameter\", \n \"dcterms:description\": \"Email address of sender.\", \n \"dcterms:title\": \"FromAddress\", \n \"ewe:example\": \"somebody@gmail.com\"\n }, \n {\n \"@id\": \"_:b2\", \n \"@type\": \"ewe:outputParameter\", \n \"dcterms:description\": \"Plain text email body.\", \n \"dcterms:title\": \"BodyPlain\", \n \"ewe:example\": \"Been having a good day so far...\"\n }, \n {\n \"@id\": \"_:b40\", \n \"@type\": \"ewe:outputParameter\", \n \"dcterms:description\": \"The filename of the first file attachment (if any).\", \n \"dcterms:title\": \"FirstAttachmentFilename\", \n \"ewe:example\": \"LadyTheDog.png\"\n }, \n {\n \"@id\": \"_:b35\", \n \"@type\": \"ewe:outputParameter\", \n \"dcterms:description\": \"Date and time email was received.\", \n \"dcterms:title\": \"ReceivedAt\", \n \"ewe:example\": \"August 23, 2010 at 11:01PM\"\n }, \n {\n \"@id\": \"_:b32\", \n \"@type\": \"ewe:outputParameter\", \n \"dcterms:description\": \"Email subject line.\", \n \"dcterms:title\": \"Subject\", \n \"ewe:example\": \"Hello there\"\n }, \n {\n \"@id\": \"_:b13\", \n \"@type\": \"ewe:outputParameter\", \n \"dcterms:description\": \"The Gmail label from trigger.\
2014-04-02 19:27:49 +00:00
}
],
2014-04-02 19:44:48 +00:00
"prompt_number": 10
2014-04-02 19:27:49 +00:00
},
{
"cell_type": "code",
"collapsed": false,
"input": "print json.dumps(ugly, indent=2)",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
2014-04-02 19:44:48 +00:00
"text": "{\n \"@context\": {\n \"foaf\": \"http://xmlns.com/foaf/0.1/\", \n \"owl\": \"http://www.w3.org/2002/07/owl#\", \n \"rdfs\": \"http://www.w3.org/2000/01/rdf-schema#\", \n \"image\": {\n \"@id\": \"http://schema.org/image\", \n \"@type\": \"@id\"\n }, \n \"tags\": \"http://www.holygoat.co.uk/owl/redwood/0.1/tags/\", \n \"ewe\": \"http://gsi.dit.upm.es/ontologies/ewe/ns/\", \n \"rdf\": \"http://www.w3.org/1999/02/22-rdf-syntax-ns#\", \n \"xsd\": \"http://www.w3.org/2001/XMLSchema#\", \n \"dcterms\": \"http://purl.org/dc/terms/\", \n \"homepage\": {\n \"@id\": \"http://schema.org/url\", \n \"@type\": \"@id\"\n }, \n \"spinrdf\": \"http://spinrdf.org/sp#\"\n }, \n \"@graph\": []\n}\n"
2014-04-02 19:27:49 +00:00
}
],
2014-04-02 19:44:48 +00:00
"prompt_number": 9
2014-04-02 19:27:49 +00:00
}
],
"metadata": {}
}
]
}