1
0
mirror of https://github.com/gsi-upm/sitc synced 2024-12-22 11:48:12 +00:00

Updated IRIs descriptions and other minor details

This commit is contained in:
Carlos A. Iglesias 2019-02-13 18:52:29 +01:00
parent 8833f09fb7
commit 19b08a1033

View File

@ -67,7 +67,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"deletable": false,
"editable": false,
@ -80,7 +80,23 @@
"solution": false
}
},
"outputs": [],
"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"
]
}
],
"source": [
"!pip install --user -r requirements.txt"
]
@ -155,7 +171,12 @@
"```\n",
"\n",
"\n",
"The second exercise will show you how to extract this information from any website."
"The second exercise will show you how to extract this information from any website.\n",
"\n",
"As you can observe in these examples, Turtle defines several ways to specify IRIs in a result. Please, consult the specification for further details. As an overview, IRIs can be:\n",
" * *relative IRIs*: IRIs resolved relative to the current base IRI. Thus, you should define a base IRI (@base <http://example.org>) and then relative IRIs (i.e. <#spiderman>). The resulting IRI is <http://example.org/spiderman>.\n",
" * *prefixed names*: a prefixed name (i.e. foaf:Person) is transformed into an IRI by concatenating the IRI of the prefix (@prefix foaf: <http://xmlns.com/foaf/0.1) and the local part of the prefixed name (i.e. Person). So, the resulting IRI is <http://xmlns.com/foaf/0.1/Person\n",
" * *absolute IRIs*: an already resolved IRI, p.ej. <http://example.com/Auto>."
]
},
{
@ -251,7 +272,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"deletable": false,
"editable": false,
@ -264,7 +285,17 @@
"solution": false
}
},
"outputs": [],
"outputs": [
{
"data": {
"application/javascript": [
"IPython.CodeCell.options_default.highlight_modes['magic_turtle'] = {'reg':[/^%%ttl/]};"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from helpers import *\n",
"from rdflib import term, RDF, Namespace"
@ -308,12 +339,14 @@
" ] .\n",
"```\n",
"\n",
"Fill in the answer and run the test code."
"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": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"deletable": false,
"nbgrader": {
@ -325,7 +358,25 @@
"solution": true
}
},
"outputs": [],
"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"
}
],
"source": [
"%%ttl example\n",
"\n",
@ -413,12 +464,9 @@
"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 have two options:\n",
" \n",
"* Use the made-up `http://example/sitc/` as base for our URIs.\n",
"For the sake of this exercise, you can 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",
"* Use (blank nodes)[https://en.wikipedia.org/wiki/Blank_node] (e.g. `_:my-fancy-hotel`), which cannot be used by other people, but can be re-used in your annotations.\n",
"\n",
"\n",
"We will use the vocabularies defined in https://schema.org e.g.:\n",
@ -428,6 +476,11 @@
"\n",
"Your definition has to be included in the following cell.\n",
"\n",
"So, your task is:\n",
"* Search the relevant properties of the vocabulary schema.org to represent the attributes of both reviews and hotels.\n",
"* Write two resources of type Hotel and three resources of type Review.\n",
"* Check that your syntax is correct, by executing your code in the cell below.\n",
"\n",
"**Tip**: Define the schema prefix first, to avoid repeating `<http://schema.org/...>`."
]
},
@ -570,18 +623,124 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"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"
}
],
"source": [
"print_data('http://www.hotellasalve.com/')"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"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"
}
],
"source": [
"print_data('https://www.mandarinoriental.com/madrid/hotel-ritz/luxury-hotel')"
]
@ -867,7 +1026,24 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"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
}
},
"nbformat": 4,