Fix installation RDF

dveni-patch-1
J. Fernando Sánchez 5 years ago
parent 19b08a1033
commit bfee8bae34

@ -67,12 +67,12 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"checksum": "387f9c38b548f29b56ae5ef5ae76fd4f",
"checksum": "6455a9642f93288f6c74b88d0892c4c7",
"grade": false,
"grade_id": "cell-d7f1ea9c021693b8",
"locked": true,
@ -80,25 +80,11 @@
"solution": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: future in /home/cif/anaconda3/lib/python3.5/site-packages (from -r requirements.txt (line 1)) (0.16.0)\n",
"Requirement already satisfied: rdflib in /home/cif/anaconda3/lib/python3.5/site-packages (from -r requirements.txt (line 2)) (4.0.1)\n",
"Requirement already satisfied: rdflib-jsonld in /home/cif/.local/lib/python3.5/site-packages (from -r requirements.txt (line 3)) (0.4.0)\n",
"Requirement already satisfied: lxml in /home/cif/anaconda3/lib/python3.5/site-packages (from -r requirements.txt (line 4)) (4.2.4)\n",
"Requirement already satisfied: html5lib in /home/cif/anaconda3/lib/python3.5/site-packages (from -r requirements.txt (line 5)) (1.0.1)\n",
"Requirement already satisfied: isodate in /home/cif/anaconda3/lib/python3.5/site-packages (from rdflib->-r requirements.txt (line 2)) (0.5.4)\n",
"Requirement already satisfied: pyparsing in /home/cif/anaconda3/lib/python3.5/site-packages (from rdflib->-r requirements.txt (line 2)) (2.2.0)\n",
"Requirement already satisfied: webencodings in /home/cif/anaconda3/lib/python3.5/site-packages (from html5lib->-r requirements.txt (line 5)) (0.5.1)\n",
"Requirement already satisfied: six>=1.9 in /home/cif/anaconda3/lib/python3.5/site-packages (from html5lib->-r requirements.txt (line 5)) (1.11.0)\n"
]
}
],
"outputs": [],
"source": [
"!pip install --user -r requirements.txt"
"# Install a pip package in the current Jupyter kernel\n",
"import sys\n",
"!{sys.executable} -m pip install -r requirements.txt\n"
]
},
{
@ -272,7 +258,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {
"deletable": false,
"editable": false,
@ -285,17 +271,7 @@
"solution": false
}
},
"outputs": [
{
"data": {
"application/javascript": [
"IPython.CodeCell.options_default.highlight_modes['magic_turtle'] = {'reg':[/^%%ttl/]};"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"from helpers import *\n",
"from rdflib import term, RDF, Namespace"
@ -306,9 +282,9 @@
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "3e23398d5277f2db2b3b5fb84f9623d6",
"checksum": "76c052d3f1117f07468068a90f969760",
"grade": true,
"grade_id": "cell-da88c2f8170436fe",
"grade_id": "cell-57f67d1e662b7f09",
"locked": false,
"points": 0,
"schema_version": 1,
@ -316,37 +292,34 @@
}
},
"source": [
"You have to fill in the parts marked:\n",
"In these exercises, you have to fill in the parts marked:\n",
"\n",
"```\n",
"# YOUR ANSWER HERE\n",
"```\n",
"\n",
"To make sure everything is working, try the following example.\n",
"The solution is:\n",
"\n",
"```turtle\n",
"@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n",
"@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .\n",
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n",
"\n",
"<http://purl.org/net/bsletten> \n",
" a foaf:Person;\n",
" foaf:interest <http://www.w3.org/2000/01/sw/>;\n",
" foaf:based_near [\n",
" geo:lat \"34.0736111\" ;\n",
" geo:lon \"-118.3994444\"\n",
" ] .\n",
"```\n",
"\n",
"Fill in the answer and run the test code.\n",
"\n",
"This order (%%ttl) is a so-called magic cell command to execute a function. You can read more here https://ipython.readthedocs.io/en/stable/interactive/magics.html#cell-magics"
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "d2a1ff53084a9bd94110f071a67d9305",
"grade": true,
"grade_id": "cell-da88c2f8170436fe",
"locked": false,
"points": 0,
"schema_version": 1,
"solution": true
}
},
"source": [
"# YOUR ANSWER HERE"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {
"deletable": false,
"nbgrader": {
@ -358,31 +331,31 @@
"solution": true
}
},
"outputs": [
{
"data": {
"text/markdown": [
"Error on line ?\n",
"\n",
"Reason: No plugin registered for (ttl, <class 'rdflib.parser.Parser'>)\n",
"\n",
"If you don't know what this error means, try an online validator: http://ttl.summerofcode.be/\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"%%ttl example\n",
"\n",
"# YOUR ANSWER HERE"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"checksum": "f6eb0c6c19c1756d7705f52866b00f82",
"grade": false,
"grade_id": "cell-a4ed500079ba36ca",
"locked": true,
"schema_version": 1,
"solution": false
}
},
"source": [
"Now run the tests:"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -390,7 +363,7 @@
"deletable": false,
"editable": false,
"nbgrader": {
"checksum": "5982ca82090e267401af135ca1f371a8",
"checksum": "7a21480d0282aed4f943d0c9d6ecd6e6",
"grade": true,
"grade_id": "cell-23e61b9f48d597fc",
"locked": true,
@ -401,6 +374,7 @@
},
"outputs": [],
"source": [
"# This code tests that the definition above is correct.\n",
"g = solution('example')\n",
"test('Some triples have been loaded',\n",
" len(g))\n",
@ -464,11 +438,10 @@
"metadata": {},
"source": [
"To make sure we are following Principles 1 and 2, we should use URIs that can be queried.\n",
"For the sake of this exercise, you can use the made-up `http://example/sitc/` as base for our URIs.\n",
"For the sake of this exercise, you have use the made-up `http://example/sitc/` as base for our URIs.\n",
"Hence, the URIs of our hotels will look like this: `http://example/sitc/my-fancy-hotel`.\n",
"These URIs can not be queried, **and should not be used in real annotations**, but we will see how to fix that in a future exercise.\n",
"\n",
"\n",
"We will use the vocabularies defined in https://schema.org e.g.:\n",
" * https://schema.org/Review defines properties about reviews\n",
" * https://schema.org/Hotel defines properties about hotels\n",
@ -623,128 +596,44 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Could not get rdfa data\n"
]
},
{
"data": {
"text/markdown": [
"\n",
"Results:\n",
"\n",
"```turtle\n",
"@prefix ns1: <http://purl.org/dc/terms/> .\n",
"@prefix ns2: <http://www.w3.org/ns/rdfa#> .\n",
"@prefix ns3: <http://www.w3.org/2006/http#> .\n",
"@prefix ns4: <http://www.w3.org/ns/md#> .\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 xml: <http://www.w3.org/XML/1998/namespace> .\n",
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n",
"\n",
"<http://www.hotellasalve.com/> ns4:item () .\n",
"\n",
"[] a ns2:Error ;\n",
" ns1:date \"2019-02-13T17:42:13.310135\"^^xsd:dateTime ;\n",
" ns1:description \"__init__() got an unexpected keyword argument 'encoding'\" ;\n",
" ns2:context [ a ns3:Request ;\n",
" ns3:requestURI \"http://www.hotellasalve.com/\" ],\n",
" [ a ns3:Response ;\n",
" ns3:responseCode <http://www.w3.org/2006/http#400> ] .\n",
"\n",
"\n",
"```\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"print_data('http://www.hotellasalve.com/')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Could not get rdfa data\n",
"https://photos.mandarinoriental.com/is/content/MandarinOriental/RZMAD - Madrid/Logos/hotel-ritz-hotel-logo-SVG.svg does not look like a valid URI, trying to serialize this will break.\n",
"tel:+34 91 701 67 67 does not look like a valid URI, trying to serialize this will break.\n"
]
},
{
"data": {
"text/markdown": [
"\n",
"Results:\n",
"\n",
"```turtle\n",
"@prefix ns1: <http://schema.org/> .\n",
"@prefix ns2: <http://www.w3.org/2006/http#> .\n",
"@prefix ns3: <http://purl.org/dc/terms/> .\n",
"@prefix ns4: <http://www.w3.org/ns/rdfa#> .\n",
"@prefix ns5: <http://www.w3.org/ns/md#> .\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 xml: <http://www.w3.org/XML/1998/namespace> .\n",
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n",
"\n",
"<https://www.mandarinoriental.com/madrid/hotel-ritz/luxury-hotel> ns5:item ( [ a ns1:Hotel ;\n",
" ns1:address [ a ns1:PostalAddress ;\n",
" ns1:addressCountry \"Spain\"@en ;\n",
" ns1:addressLocality \"Madrid\"@en ;\n",
" ns1:postalCode \"28014\"@en ;\n",
" ns1:streetAddress \"Plaza de la Lealtad 5\"@en ] ;\n",
" ns1:description \"Experience our 5 Star hotel in central Madrid, Retiro Park offering luxurious rooms and suites, fine dining, private spa, meeting and wedding facilities.\"@en ;\n",
" ns1:email <mailto:reservations@mohg.com> ;\n",
" ns1:image <https%3A//photos.mandarinoriental.com/is/content/MandarinOriental/RZMAD%20-%20Madrid/Logos/hotel-ritz-hotel-logo-SVG.svg> ;\n",
" ns1:name \"Hotel Ritz, Madrid\"@en ;\n",
" ns1:tel <tel%3A%2B34%2091%20701%2067%2067> ;\n",
" ns1:url <https://www.google.com/maps/place/Hotel+Ritz,+Madrid/@40.4156097,-3.6946249,773m/data=!3m2!1e3!4b1!4m5!3m4!1s0xd42288329bef061:0xb9bba45ac90e2184!8m2!3d40.4156056!4d-3.6924362>,\n",
" <https://www.mandarinoriental.com/> ] ) ;\n",
" ns4:usesVocabulary ns1: .\n",
"\n",
"[] a ns4:Error ;\n",
" ns3:date \"2019-02-13T17:43:52.577508\"^^xsd:dateTime ;\n",
" ns3:description \"__init__() got an unexpected keyword argument 'encoding'\" ;\n",
" ns4:context [ a ns2:Request ;\n",
" ns2:requestURI \"https://www.mandarinoriental.com/madrid/hotel-ritz/luxury-hotel\" ],\n",
" [ a ns2:Response ;\n",
" ns2:responseCode <http://www.w3.org/2006/http#400> ] .\n",
"\n",
"\n",
"```\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"print_data('https://www.mandarinoriental.com/madrid/hotel-ritz/luxury-hotel')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "c7af0b9af5a64773785cc890f2431c78",
"grade": true,
"grade_id": "cell-c2e5b58ea74e8276",
"locked": false,
"points": 1,
"schema_version": 1,
"solution": true
}
},
"outputs": [],
"source": [
"# Try new sites here\n",
"\n",
"# YOUR ANSWER HERE"
]
},
{
"cell_type": "markdown",
"metadata": {
@ -773,11 +662,11 @@
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "2a7a6ab7d69f7ca5db64233128260045",
"checksum": "56a77e133b532997723bf2f8116389e4",
"grade": true,
"grade_id": "cell-17508ecf96884653",
"locked": false,
"points": 0,
"points": 1,
"schema_version": 1,
"solution": true
}
@ -792,7 +681,7 @@
"deletable": false,
"editable": false,
"nbgrader": {
"checksum": "531928c9e3b8462baddd4d700c240995",
"checksum": "9311bca044d7057c86dd753f5343e19b",
"grade": false,
"grade_id": "cell-d36826d6323c96e8",
"locked": true,
@ -801,7 +690,7 @@
}
},
"source": [
"What vocabularyes and ontologies do they use?"
"What vocabularies and ontologies do they use?"
]
},
{
@ -809,11 +698,11 @@
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "f100004eceae0c8159ade9d713af47e7",
"checksum": "ba7b24b557d627e2665ca31c75c24c23",
"grade": true,
"grade_id": "cell-17508ecf96884655",
"locked": false,
"points": 0,
"points": 1,
"schema_version": 1,
"solution": true
}
@ -824,9 +713,20 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"checksum": "853651c95cbcd69cd5f495f03d29d19a",
"grade": false,
"grade_id": "cell-e25a0db3fe8a6b4b",
"locked": true,
"schema_version": 1,
"solution": false
}
},
"source": [
"What are the similarities between sites"
"What properties and annotations do they have in common?"
]
},
{
@ -834,11 +734,11 @@
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "3d9ad086580ee27d93395dac8c16551d",
"checksum": "779f0f750508eb52b2d98b92689e426b",
"grade": true,
"grade_id": "cell-30797c9ac87cc7e1",
"locked": false,
"points": 0,
"points": 1,
"schema_version": 1,
"solution": true
}
@ -847,36 +747,22 @@
"# YOUR ANSWER HERE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What are the similarities between sites"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"checksum": "4c03ad45eb1234cadccab2b468a69123",
"grade": true,
"grade_id": "answer-similarities",
"locked": false,
"points": 0,
"checksum": "f8fff644855ca50a5219598322aa9b32",
"grade": false,
"grade_id": "cell-33862c8e38173d9c",
"locked": true,
"schema_version": 1,
"solution": true
"solution": false
}
},
"source": [
"# YOUR ANSWER HERE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What are the biggest differences"
"What sites provide the most, or the most useful annotations?"
]
},
{
@ -884,11 +770,11 @@
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "6ccc2db2be4826a146a6c34bc54f00de",
"checksum": "8ef0ebd54eefb44ff7019f17f58be3ec",
"grade": true,
"grade_id": "cell-17508ecf96884657",
"locked": false,
"points": 0,
"points": 1,
"schema_version": 1,
"solution": true
}
@ -920,11 +806,11 @@
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "e0b4d9f1a2dfe5a7ab835f7349aa3796",
"checksum": "b5f208a95a8803e97f82c5f2cdf319dd",
"grade": true,
"grade_id": "answer-missing",
"locked": false,
"points": 0,
"points": 1,
"schema_version": 1,
"solution": true
}
@ -974,6 +860,27 @@
"print_data('https://mastodon.social/@Gargron')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "fb8bd92e931c7836bb3c22dadd3be583",
"grade": true,
"grade_id": "cell-ff2413f45311f086",
"locked": false,
"points": 0,
"schema_version": 1,
"solution": true
}
},
"outputs": [],
"source": [
"# Try some new sites here.\n",
"# YOUR ANSWER HERE"
]
},
{
"cell_type": "markdown",
"metadata": {
@ -1026,24 +933,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.5"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
"version": "3.7.2"
}
},
"nbformat": 4,

@ -53,7 +53,7 @@ If you don\'t know what this error means, try an online validator: http://ttl.su
key = line or 'default'
try:
DEFINITIONS[key] = g.parse(data=cell,
format="ttl")
format="n3")
except SyntaxError as ex:
return Markdown(msg.format(line=ex.lines, reason=ex._why))
except Exception as ex:

Loading…
Cancel
Save