{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "1fba29f718bbaa14890b305223712474",
     "grade": false,
     "grade_id": "cell-2bd9e19ffed99f81",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "<header style=\"width:100%;position:relative\">\n",
    "  <div style=\"width:80%;float:right;\">\n",
    "    <h1>Course Notes for Learning Intelligent Systems</h1>\n",
    "    <h3>Department of Telematic Engineering Systems</h3>\n",
    "    <h5>Universidad Politécnica de Madrid</h5>\n",
    "  </div>\n",
    "        <img style=\"width:15%;\" src=\"../logo.jpg\" alt=\"UPM\" />\n",
    "</header>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "845cf125f1c5eb7aa3653ef461bffc67",
     "grade": false,
     "grade_id": "cell-51338a0933103db9",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "# Introduction\n",
    "\n",
    "The goal of this exercise is to understand the usefulness of semantic annotation and the Linked Open Data initiative, by solving a practical use case.\n",
    "\n",
    "The student will achieve the goal through:\n",
    "\n",
    "* Analyzing the sequence of tasks required to generate and publish semantic data\n",
    "* Extending their knowledge using the set of additional documents and specifications\n",
    "* Creating a partial semantic definition using the Turtle format\n",
    "\n",
    "\n",
    "# Objectives\n",
    "\n",
    "The main objective is to learn how annotations can be unified on the web, by following the Linked Data principles.\n",
    "\n",
    "\n",
    "These concepts will be applied in a practical use case: obtaining a Graph of information about hotels and reviews about them.\n",
    "\n",
    "\n",
    "# Tools\n",
    "\n",
    "This notebook is self-contained, but it requires some python libraries.\n",
    "To install them, simply run the following line:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Install a pip package in the current Jupyter kernel.\n",
    "import sys\n",
    "import site\n",
    "usersite = site.getusersitepackages()\n",
    "if usersite not in sys.path:\n",
    "    sys.path.append(usersite)\n",
    "!{sys.executable} -m pip install --user -r requirements.txt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "753edf07d500cc7f9cc9c5a4c0a1348e",
     "grade": false,
     "grade_id": "cell-d8db3c16cee92ac1",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "# Linked Data, RDF and Turtle\n",
    "\n",
    "\n",
    "The term [Linked Data](https://www.w3.org/wiki/LinkedData) refers to a set of best practices for publishing structured data on the Web.\n",
    "These principles have been coined by Tim Berners-Lee in the design issue note Linked Data.\n",
    "The principles are:\n",
    "\n",
    "1. Use URIs as names for things\n",
    "2. Use HTTP URIs so that people can look up those names\n",
    "3. When someone looks up a URI, provide useful information\n",
    "4. Include links to other URIs, so that they can discover more things\n",
    "\n",
    "The [RDF](https://www.w3.org/RDF/) is a standard model for data interchange on the Web.\n",
    "It formalizes some concepts behind Linked Data into a specification, which can be used to develop applications and store information.\n",
    "\n",
    "Explaining RDF is out of the scope of this notebook.\n",
    "The [resources section](#Useful-resources) contains some links if you wish to learn about RDF.\n",
    "\n",
    "The main idea behind RDF is that information is encoded in the form of triples:\n",
    "\n",
    "```turtle\n",
    "<subject> <predicate> <object>\n",
    "```\n",
    "\n",
    "Each of these, (`<subject>`, `<predicate>` and `<object>`) should be unique identifiers.\n",
    "\n",
    "For example, to say Timmy is a 7 year-old whose dog is Tobby, we would write:\n",
    "\n",
    "```turtle\n",
    "<http://example.org/Timmy>  <http://example.org/hasDog> <http://example.org/Tobby>\n",
    "<http://example.org/Timmy>  <http://example.org/age> 7\n",
    "```\n",
    "\n",
    "Note that we are not referring to \"any Timmy\", but to a *very specific* Timmy.\n",
    "We could learn more about this particular boy using that URI.\n",
    "The same goes for the dog, and for the concept of \"having a dog\", which we unambiguously encode as `<http://example.org/hasDog>`.\n",
    "This concept may be described as taking care of a dog, for example, whereas a different property `<http://yourwebsite.com/hasDog>` could be described as being the legal owner of the dog.\n",
    "\n",
    "\n",
    "RDF can be used to embed annotation in many places, including HTML document, using any compatible format.\n",
    "The options include including RDFa, XML, JSON-LD and [Turtle](https://www.w3.org/TR/turtle/).\n",
    "\n",
    "\n",
    "In the exercises, we will be using turtle notation, because it is very readable.\n",
    "\n",
    "For instance, turtle allows us to re-use parts of a previous triple to avoid repetition.\n",
    "Our previous example would look like this:\n",
    "\n",
    "```turtle\n",
    "<http://example.org/Timmy>  <http://example.org/hasDog> <http://example.org/Tobby> ;\n",
    "                            <http://example.org/age> 7\n",
    "```\n",
    "\n",
    "Here's another example of document in Turtle, taken from the Turtle specification:\n",
    "\n",
    "```turtle\n",
    "@base <http://example.org/> .\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 foaf: <http://xmlns.com/foaf/0.1/> .\n",
    "@prefix rel: <http://www.perceive.net/schemas/relationship/> .\n",
    "\n",
    "<#green-goblin> a foaf:Person ;             # Green Goblin is a person\n",
    "                foaf:name \"Green Goblin\" ;\n",
    "                rel:enemyOf <#spiderman> .  # Green Goblin is one of Spiderman's enemies \n",
    "\n",
    "<#spiderman> a foaf:Person ;  # Spiderman is also a person\n",
    "             foaf:name \"Spiderman\", \"Человек-паук\"@ru .  # Spiderman's name in Russian is Человек-паук\n",
    "             rel:enemyOf <#green-goblin> ; \n",
    "```\n",
    "\n",
    "\n",
    "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>."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "d2849a6154d4807b405e6ec84601c231",
     "grade": false,
     "grade_id": "cell-14e2327285737802",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "# Vocabularies and schema.org\n",
    "\n",
    "Concepts (predicates, types, etc.) can be defined in vocabularies.\n",
    "These vocabularies can be reused in several applications.\n",
    "In the example above, we used the concept of person from an external vocabulary (`foaf:Person`, i.e. http://xmlns.com/foaf/0.1/Person).\n",
    "That way, we do not need to redefine the concept of Person in every application.\n",
    "There are several well known vocabularies, such as:\n",
    "\n",
    "* Dublin core, for metadata: http://dublincore.org/\n",
    "* FOAF (Friend-of-a-friend) for social networks: http://www.foaf-project.org/\n",
    "* SIOC for online communities: https://www.w3.org/Submission/sioc-spec/\n",
    "\n",
    "Using the same vocabularies also makes it easier to automatically process and classify information.\n",
    "\n",
    "\n",
    "That was the motivation behind Schema.org, a collaboration between Google, Microsoft, Yahoo and Yandex.\n",
    "They aim to provide schemas for structured data annotation of Web sites, e-mails, etc., which can be leveraged by search engines and other automated processes.\n",
    "\n",
    "They rely on RDF for representation, and provide a set of common vocabularies that can be shared by every web developer.\n",
    "\n",
    "\n",
    "There are thousands of properties in the schema.org vocabulary, and they offer a very comprehensive documentation.\n",
    "\n",
    "As an example, this is the documentation for hotels:\n",
    "\n",
    "* List of properties for the Hotel type: https://schema.org/Hotel\n",
    "* Documentation for hotels: https://schema.org/docs/hotels.html\n",
    "\n",
    "\n",
    "You can use the documentation to find properties (e.g. `checkinTime`), as well as the type of that property (e.g. `Datetime`)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "fe9a246ba580c71385e9b83d414a1216",
     "grade": false,
     "grade_id": "cell-a1b60daabb1a9d00",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "# Exercises"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "63879c425ec11742c95c728a578d109e",
     "grade": false,
     "grade_id": "cell-d9289e96b2b0f265",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "## Instructions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "32f1f607adb584aaea9fb90ae4d805b5",
     "grade": false,
     "grade_id": "cell-bb418e9bae1fef1a",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "First of all, run the line below to import everything you need for the exercises."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "892f8491591c25defdea5fdcdd289489",
     "grade": false,
     "grade_id": "cell-4a1b60bd9974bbb1",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "outputs": [],
   "source": [
    "from helpers import *"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "a855d3d63be5ea7f73fd85d645b21bfe",
     "grade": true,
     "grade_id": "cell-9ac392294d5708a1",
     "locked": false,
     "points": 0,
     "schema_version": 3,
     "solution": true
    }
   },
   "source": [
    "In these exercises, you have to fill in the parts marked:\n",
    "\n",
    "```\n",
    "# YOUR ANSWER HERE\n",
    "```\n",
    "\n",
    "Depending on the exercise, you might need to fill that part with a Turtle definition (first exercise), some python code (second exercise), or plain text."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "9a73f79f8f282874fb60011e6019e387",
     "grade": false,
     "grade_id": "cell-57f67d1e662b7f09",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "Turtle is usually written in standalone files (e.g. `mydefinition.ttl`).\n",
    "To write Turtle definitions inside notebook cells we will use a special magic command: `%%ttl`.\n",
    "The command will check the Turtle syntax of your definition, and provide syntax highlighting.\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "18ad887c2f326ee59139b96860ce8893",
     "grade": false,
     "grade_id": "cell-16214ea73a9b689e",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "## Example"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "ed2466715f57356f22ddeabfb101eb11",
     "grade": false,
     "grade_id": "cell-da88c2f8170436fe",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "\n",
    "To make sure everything works, let's try first with an example exercise.\n",
    "\n",
    "Execute the code below, without modification.\n",
    "\n",
    "The definitio **is empty but valid**, so the output will be `The turtle syntax is correct.`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "69182e8fadb9c9751f76786e0fcb8803",
     "grade": false,
     "grade_id": "cell-808cfcbf3891f39f",
     "locked": false,
     "schema_version": 3,
     "solution": true
    }
   },
   "outputs": [],
   "source": [
    "%%ttl example\n",
    "\n",
    "# YOUR ANSWER HERE"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "60a9934c544eee9fc2c3745c36beb049",
     "grade": false,
     "grade_id": "cell-1c2ca86de107dec3",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "However, the definition is empty, so the tests for that definition **should fail**.\n",
    "\n",
    "Try it yourself by running the following line:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "12b5c7170326932ff3c7e1688a5769b2",
     "grade": false,
     "grade_id": "cell-0154f8481bf393e8",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "outputs": [],
   "source": [
    "# This will check your definition for the example.\n",
    "check('example')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "b534d998c6d2e9f6bef8c2d88687a96b",
     "grade": false,
     "grade_id": "cell-adc7e6b7e96e8788",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "Now copy/paste the code below into the definition (below the `# YOUR ANSWER HERE` part), execute it, and run the test code again.\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",
    "If you copied the file right, the tests should pass."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "67540252804835faea83d96aab87aa29",
     "grade": false,
     "grade_id": "cell-e73f1933742f7ab3",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "## Exercise 1: Definition of hotels and reviews"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We will define some basic information about hotels, and some reviews.\n",
    "This should be the same type of information that some aggregators (e.g. TripAdvisor) offer in their websites.\n",
    "\n",
    "Namely, you need to define at least two hotels (you may add more than one), with the following information:\n",
    "* Description\n",
    "* Address\n",
    "* Contact information\n",
    "* City and country (location)\n",
    "* Email\n",
    "* logo\n",
    "* Opening hours\n",
    "* Price range\n",
    "* Amenities (optional)\n",
    "* Geolocation (optional)\n",
    "* Images (optional)\n",
    "\n",
    "You should also add at least three reviews about hotels, with the following information:\n",
    "* Name of the user that reviewed the Hotel\n",
    "* Rating\n",
    "* Date\n",
    "* Replies by other users (optional)\n",
    "* Aspects rated in each review (cleanliness, staff, etc...) (optional)\n",
    "* Information about the user (name, surname, date the account was created) (optional)\n",
    "\n",
    "\n",
    "You can check any hotel website for inspiration, like this [review of a hotel in TripAdvisor](https://www.tripadvisor.es/Hotel_Review-g1437655-d1088667-Reviews-Hotel_Spa_La_Salve-Torrijos_Province_of_Toledo_Castile_La_Mancha.html)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "d6f1bf2230282256e5fcb85dba0eef45",
     "grade": false,
     "grade_id": "cell-3241bf07ae153beb",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "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 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",
    "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",
    "    \n",
    "\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/...>`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "44f8be14db3d3e42b5b85f0485206346",
     "grade": false,
     "grade_id": "definition",
     "locked": false,
     "schema_version": 3,
     "solution": true
    }
   },
   "outputs": [],
   "source": [
    "%%ttl hotel\n",
    "\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 sitc: <http://example/sitc/> .\n",
    "\n",
    "\n",
    "<http://example/sitc/GSIHOTEL> a <http://schema.org/Hotel> ;\n",
    "         <http://schema.org/description> \"This is just an example to get you started.\" .\n",
    "\n",
    "\n",
    "# YOUR ANSWER HERE"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "e8ba71b32e6d4f15aef9dc7fe70387fe",
     "grade": true,
     "grade_id": "cell-2fb6e144a6691ede",
     "locked": true,
     "points": 10,
     "schema_version": 3,
     "solution": false
    }
   },
   "outputs": [],
   "source": [
    "# This will check that your definition for the first exercise is correct.\n",
    "check('hotel')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "75d90c9a83c694f61e51bd5c47a672d9",
     "grade": false,
     "grade_id": "cell-63a55e7b8b195d59",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "## Exercise 2: Explore existing data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "23632182da48df109721378408e57f01",
     "grade": false,
     "grade_id": "cell-3843c3ce98a77c56",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "The goal of this exercise is to explore and compare annotations from existing websites.\n",
    "\n",
    "Semantic annotations are very useful on the web, because they allow `robots` to extract information about resources, and how they relate to other resources.\n",
    "\n",
    "For example, `schema.org` annotations on a website allow Google to show summaries and useful information (e.g. price and location of a hotel) in their results.\n",
    "A similar technology powers their knowledge graph and the \"related search\". i.e. when you look for a famous actor, it will first show you their filmography, and a list of related actors.\n",
    "\n",
    "The information has to be provided using the official standards (RDF), to comply with the 3rd principle of linked data.\n",
    "\n",
    "To follow the 4<sup>th</sup> principle of linked data, the annotations should include links to known sources (e.g. DBpedia) whenever possible."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "6c4b25718f493ad5964370f412519543",
     "grade": false,
     "grade_id": "cell-f42c087c9065bb23",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "Let us explore some semantic annotations from popular websites.\n",
    "\n",
    "First, start with hotel reviews and websites. Here are some examples:\n",
    "\n",
    "* TripAdvisor hotels\n",
    "* Trivago\n",
    "* Kayak\n",
    "* Specific hotel reviews\n",
    "\n",
    "\n",
    "These are just two examples:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print_data('http://www.hotellasalve.com/')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print_data('https://www.mandarinoriental.com/madrid/hotel-ritz/luxury-hotel')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "c7af0b9af5a64773785cc890f2431c78",
     "grade": true,
     "grade_id": "cell-c2e5b58ea74e8276",
     "locked": false,
     "points": 1,
     "schema_version": 3,
     "solution": true
    }
   },
   "outputs": [],
   "source": [
    "# Try new sites here\n",
    "\n",
    "# YOUR ANSWER HERE"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "a29112f51cc3299c7cae27841feb7410",
     "grade": false,
     "grade_id": "cell-9bf9c7d7516fae75",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "Once you've extracted and analyzed different sources, answer the following questions:\n",
    "\n",
    "\n",
    "### Questions:\n",
    "\n",
    "What type of data do they offer?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "56a77e133b532997723bf2f8116389e4",
     "grade": true,
     "grade_id": "cell-17508ecf96884653",
     "locked": false,
     "points": 1,
     "schema_version": 3,
     "solution": true
    }
   },
   "source": [
    "# YOUR ANSWER HERE"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "9311bca044d7057c86dd753f5343e19b",
     "grade": false,
     "grade_id": "cell-d36826d6323c96e8",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "What vocabularies and ontologies do they use?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "ba7b24b557d627e2665ca31c75c24c23",
     "grade": true,
     "grade_id": "cell-17508ecf96884655",
     "locked": false,
     "points": 1,
     "schema_version": 3,
     "solution": true
    }
   },
   "source": [
    "# YOUR ANSWER HERE"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "853651c95cbcd69cd5f495f03d29d19a",
     "grade": false,
     "grade_id": "cell-e25a0db3fe8a6b4b",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "What properties and annotations do they have in common?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "779f0f750508eb52b2d98b92689e426b",
     "grade": true,
     "grade_id": "cell-30797c9ac87cc7e1",
     "locked": false,
     "points": 1,
     "schema_version": 3,
     "solution": true
    }
   },
   "source": [
    "# YOUR ANSWER HERE"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "f8fff644855ca50a5219598322aa9b32",
     "grade": false,
     "grade_id": "cell-33862c8e38173d9c",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "What sites provide the most, or the most useful annotations?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "8ef0ebd54eefb44ff7019f17f58be3ec",
     "grade": true,
     "grade_id": "cell-17508ecf96884657",
     "locked": false,
     "points": 1,
     "schema_version": 3,
     "solution": true
    }
   },
   "source": [
    "# YOUR ANSWER HERE"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "33e1ec78415c85a795e86211d88316c2",
     "grade": false,
     "grade_id": "cell-5f922dc14ad3236a",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "Are all properties from Exercise 1 given by the websites? What's missing?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "b5f208a95a8803e97f82c5f2cdf319dd",
     "grade": true,
     "grade_id": "answer-missing",
     "locked": false,
     "points": 1,
     "schema_version": 3,
     "solution": true
    }
   },
   "source": [
    "# YOUR ANSWER HERE"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "26eb04e562aa6c7d29efa8318982a337",
     "grade": false,
     "grade_id": "cell-7a3c1553c4d6a9b7",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "## Optional\n",
    "\n",
    "There is nothing special about review sites.\n",
    "You can get information about any website.\n",
    "\n",
    "Verify this running checking:\n",
    "\n",
    "* News sites: e.g. https://edition.cnn.com/\n",
    "* CMS: e.g. http://www.etsit.upm.es\n",
    "* Twitter profiles: e.g. https://www.twitter.com/cif\n",
    "* Mastodon (a Twitter alternative) profiles: e.g. https://mastodon.social/@Gargron/\n",
    "* Twitter status pages: e.g. http://mobile.twitter.com/TBLInternetBot/status/1054438951237312514\n",
    "* Mastodon (a Twitter alternative) status pages: e.g. https://mastodon.social/@Gargron/101202440923902326\n",
    "* Wikipedia entries: e.g. https://es.wikipedia.org/wiki/Tim_Berners-Lee\n",
    "* Facebook groups: e.g. https://www.facebook.com/universidadpolitecnicademadrid/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print_data('https://mastodon.social/@Gargron')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now try some new sites:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "bf8d215c42321236b783601e7d072a05",
     "grade": true,
     "grade_id": "cell-ff2413f45311f086",
     "locked": false,
     "points": 0,
     "schema_version": 3,
     "solution": true
    }
   },
   "outputs": [],
   "source": [
    "# YOUR ANSWER HERE"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "cffc12120c51a7d994063f66d788570a",
     "grade": false,
     "grade_id": "cell-ec8df1a53c3d3f23",
     "locked": true,
     "schema_version": 3,
     "solution": false
    }
   },
   "source": [
    "# Useful resources\n",
    "\n",
    "* TTL validator: http://ttl.summerofcode.be/\n",
    "* RDF-turtle specification: https://www.w3.org/TR/turtle/\n",
    "* Schema.org documentation: https://schema.org\n",
    "* Wikipedia entry on the Turtle syntax: https://en.wikipedia.org/wiki/Turtle_(syntax)\n",
    "* RDFLib, the most popular python library for RDF (we use it in the tests): https://rdflib.readthedocs.io/"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Bibliography\n",
    "\n",
    "* W3C website on Linked Data: https://www.w3.org/wiki/LinkedData\n",
    "* W3C website on RDF: https://www.w3.org/RDF/\n",
    "* Turtle W3C recommendation: https://www.w3.org/TR/turtle/"
   ]
  }
 ],
 "metadata": {
  "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.8.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
