mirror of
https://github.com/gsi-upm/sitc
synced 2024-12-22 03:38:13 +00:00
Actualizar ejercicios LOD
This commit is contained in:
parent
41d3bdea75
commit
897bb487b1
@ -124,7 +124,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%sparql https://live.dbpedia.org/sparql\n",
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"SELECT ?s ?p ?o\n",
|
||||
"WHERE {\n",
|
||||
@ -149,7 +149,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%sparql https://live.dbpedia.org/sparql\n",
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"SELECT *\n",
|
||||
"WHERE\n",
|
||||
@ -445,7 +445,7 @@
|
||||
"window_display": false
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@ -459,7 +459,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.1"
|
||||
"version": "3.8.10"
|
||||
},
|
||||
"latex_envs": {
|
||||
"LaTeX_envs_menu_present": true,
|
||||
|
@ -1915,5 +1915,5 @@
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
|
@ -441,7 +441,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@ -455,7 +455,20 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.1"
|
||||
"version": "3.8.10"
|
||||
},
|
||||
"toc": {
|
||||
"base_numbering": 1,
|
||||
"nav_menu": {},
|
||||
"number_sections": true,
|
||||
"sideBar": true,
|
||||
"skip_h1_title": false,
|
||||
"title_cell": "Table of Contents",
|
||||
"title_sidebar": "Contents",
|
||||
"toc_cell": false,
|
||||
"toc_position": {},
|
||||
"toc_section_display": true,
|
||||
"toc_window_display": false
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
@ -259,10 +259,11 @@
|
||||
"source": [
|
||||
"Now that you have some experience under your belt, it is time to design your own query.\n",
|
||||
"\n",
|
||||
"Your first task it to get a list of Spanish Novelits, using the skeleton below and the previous query to guide you.\n",
|
||||
"Your first task it to get a list of writers, using the skeleton below and the previous query to guide you.\n",
|
||||
"\n",
|
||||
"Pages for Spanish novelists are grouped in the *Spanish novelists* DBpedia category. You can use that fact to get your list.\n",
|
||||
"In other words, the difference from the previous query will be using `dct:subject` instead of `dbo:isPartOf`, and `dbc:Spanish_novelists` instead of `dbr:Community_of_Madrid`."
|
||||
"The DBpedia vocabulary has a special class for writers: `<http://dbpedia.org/ontology/Writer>`.\n",
|
||||
"\n",
|
||||
"In other words, the difference from the previous query will be using `a` instead of `dbo:isPartOf`, and `dbo:Writer` instead of `dbr:Community_of_Madrid`."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -272,7 +273,7 @@
|
||||
"deletable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "4f753f7c895d2f65fa9fcda462f8adda",
|
||||
"checksum": "2a5c55e8bca983aca6cc2293f4560f31",
|
||||
"grade": false,
|
||||
"grade_id": "cell-7a9509ff3c34127e",
|
||||
"locked": false,
|
||||
@ -285,7 +286,7 @@
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"PREFIX dct:<http://purl.org/dc/terms/>\n",
|
||||
"PREFIX dbc:<http://dbpedia.org/resource/Category:>\n",
|
||||
"PREFIX dbo:<http://dbpedia.org/ontology/>\n",
|
||||
"\n",
|
||||
"SELECT ?escritor\n",
|
||||
"\n",
|
||||
@ -366,7 +367,7 @@
|
||||
"source": [
|
||||
"Time to try it yourself.\n",
|
||||
"\n",
|
||||
"Get the list of Spanish novelists AND their name (using rdfs:label)."
|
||||
"Get the list of writers AND their name (using rdfs:label)."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -408,7 +409,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "b6bcf798e1d8784ecfe11ccb3d621bdd",
|
||||
"checksum": "d779d690d5d1865973fdcf113b74c221",
|
||||
"grade": true,
|
||||
"grade_id": "cell-8afd28aada7a896c",
|
||||
"locked": true,
|
||||
@ -420,8 +421,8 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert 'escritor' in solution()['columns']\n",
|
||||
"assert 'http://dbpedia.org/resource/Luis_Coloma' in solution()['columns']['escritor']\n",
|
||||
"assert ('http://dbpedia.org/resource/Luis_Coloma', 'Luis Coloma') in solution()['tuples']"
|
||||
"assert 'http://dbpedia.org/resource/Alison_Stine' in solution()['columns']['escritor']\n",
|
||||
"assert ('http://dbpedia.org/resource/Alistair_MacLeod', 'Alistair MacLeod') in solution()['tuples']"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -438,9 +439,10 @@
|
||||
"In the previous example, we saw that we got what seemed to be duplicated answers.\n",
|
||||
"\n",
|
||||
"This happens because entities can have labels in different languages (e.g. English, Spanish).\n",
|
||||
"To restrict the search to only those results we're interested in, we can use filtering.\n",
|
||||
"We can filter results using the `FILTER` keyword.\n",
|
||||
"\n",
|
||||
"We can also decide the order in which our results are shown.\n",
|
||||
"We can also decide the order in which our results are shown using the `ORDER BY` sentence.\n",
|
||||
"We can order in ascending (`ASC`) or descending (`DESC`) order.\n",
|
||||
"\n",
|
||||
"For instance, this is how we could use filtering to get only large areas in our example, in descending order:"
|
||||
]
|
||||
@ -464,7 +466,7 @@
|
||||
" ?localidad dbo:type dbr:Municipalities_of_Spain .\n",
|
||||
" FILTER(?area > 100000)\n",
|
||||
"}\n",
|
||||
"ORDER BY ?pop\n",
|
||||
"ORDER BY DESC(?area)\n",
|
||||
"LIMIT 100"
|
||||
]
|
||||
},
|
||||
@ -483,7 +485,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "9485c62a83314be3c6e0c2ce0ab1ff2e",
|
||||
"checksum": "1e09f3c1749dd3c9256a1d0bbc14ff2d",
|
||||
"grade": true,
|
||||
"grade_id": "cell-cb7b8283568cd349",
|
||||
"locked": true,
|
||||
@ -495,7 +497,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# We still have the biggest city\n",
|
||||
"assert ('http://dbpedia.org/resource/Orcasur', '14264', '2020') in solution()['tuples']\n",
|
||||
"assert 'http://dbpedia.org/resource/Úbeda' in solution()['columns']['localidad']\n",
|
||||
"# But the smaller ones are gone\n",
|
||||
"assert 'http://dbpedia.org/resource/El_Cañaveral' not in solution()['columns']['localidad']"
|
||||
]
|
||||
@ -514,7 +516,7 @@
|
||||
"deletable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "0545d89afc6fbb3001240d50c74dce77",
|
||||
"checksum": "b200ff7d97fe03bab726040d16b636fe",
|
||||
"grade": false,
|
||||
"grade_id": "cell-ff3d611cb0304b01",
|
||||
"locked": false,
|
||||
@ -528,7 +530,7 @@
|
||||
"\n",
|
||||
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||
"PREFIX dct:<http://purl.org/dc/terms/>\n",
|
||||
"PREFIX dbc:<http://dbpedia.org/resource/Category:>\n",
|
||||
"PREFIX dbo:<http://dbpedia.org/ontology/>\n",
|
||||
"\n",
|
||||
"SELECT ?escritor ?nombre\n",
|
||||
"\n",
|
||||
@ -536,7 +538,7 @@
|
||||
"# YOUR ANSWER HERE\n",
|
||||
"}\n",
|
||||
"# YOUR ANSWER HERE\n",
|
||||
"LIMIT 1000"
|
||||
"LIMIT 100"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -547,7 +549,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "3441fbd2267002acbb0d46d9ce94ba97",
|
||||
"checksum": "637f8a2e0eb286f968f22b0e0fa2215a",
|
||||
"grade": true,
|
||||
"grade_id": "cell-d70cc6ea394741bc",
|
||||
"locked": true,
|
||||
@ -559,8 +561,8 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert len(solution()['tuples']) >= 50\n",
|
||||
"assert 'Adelaida García Morales' in solution()['columns']['nombre']\n",
|
||||
"assert sum(1 for k in solution()['columns']['escritor'] if k == 'http://dbpedia.org/resource/Adelaida_García_Morales') == 1"
|
||||
"assert 'Abraham Abulafia' in solution()['columns']['nombre']\n",
|
||||
"assert sum(1 for k in solution()['columns']['escritor'] if k == 'http://dbpedia.org/resource/Abraham_Abulafia') == 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -575,8 +577,9 @@
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"From now on, we will focus on our Writers example.\n",
|
||||
"More specifically, we will be interested in writers born in the XX century.\n",
|
||||
"\n",
|
||||
"First, we will search for writers born in the XX century, using the [20th-century Spanish novelists](http://dbpedia.org/page/Category:20th-century_Spanish_novelists) category."
|
||||
"To do that, we will filter our novelists to only those born (`dbo:birthDate`) in the 20th century (after 1900)."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -607,7 +610,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "cacdd08a8a267c1173304e319ffff563",
|
||||
"checksum": "e896e64c21f317aeacf82ccd46811059",
|
||||
"grade": true,
|
||||
"grade_id": "cell-cf3821f2d33fb0f6",
|
||||
"locked": true,
|
||||
@ -618,9 +621,9 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert 'Camilo José Cela' in solution()['columns']['nombre']\n",
|
||||
"assert 'Javier Marías' in solution()['columns']['nombre']\n",
|
||||
"assert all(x > '1850-12-31' and x < '2001-01-01' for x in solution()['columns']['nac'])"
|
||||
"assert 'Kiku Amino' in solution()['columns']['nombre']\n",
|
||||
"assert 'Albert Hackett' in solution()['columns']['nombre']\n",
|
||||
"assert all(x > '1900-01-01' and x < '2001-01-01' for x in solution()['columns']['nac'])"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -643,7 +646,7 @@
|
||||
"deletable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "e8dcfee69cc653b9e09c2b6ba2e2fa97",
|
||||
"checksum": "df4364d90fd37ec886bec8f39f6df8ee",
|
||||
"grade": false,
|
||||
"grade_id": "cell-254a18dd973e82ed",
|
||||
"locked": false,
|
||||
@ -657,7 +660,6 @@
|
||||
"\n",
|
||||
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||
"PREFIX dct:<http://purl.org/dc/terms/>\n",
|
||||
"PREFIX dbc:<http://dbpedia.org/resource/Category:>\n",
|
||||
"PREFIX dbo:<http://dbpedia.org/ontology/>\n",
|
||||
"\n",
|
||||
"SELECT ?escritor ?nombre ?fechaNac ?fechaDef\n",
|
||||
@ -666,7 +668,7 @@
|
||||
"# YOUR ANSWER HERE\n",
|
||||
"}\n",
|
||||
"# YOUR ANSWER HERE\n",
|
||||
"LIMIT 2000"
|
||||
"LIMIT 100"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -677,7 +679,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "5c01a467c0e3f3fa8c13dc7648696858",
|
||||
"checksum": "26d08d050ac6963b20595f52b5d14781",
|
||||
"grade": true,
|
||||
"grade_id": "cell-4d6a64dde67f0e11",
|
||||
"locked": true,
|
||||
@ -688,7 +690,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert 'Carmen Laforet' in solution()['columns']['nombre']\n",
|
||||
"assert 'Alister McGrath' in solution()['columns']['nombre']\n",
|
||||
"# assert '1879-2-11' in solution()['columns']['fechaNac']\n",
|
||||
"assert '' in solution()['columns']['fechaNac'] # Not all birthdates are defined\n",
|
||||
"assert '' in solution()['columns']['fechaDef'] # Some deathdates are not defined"
|
||||
@ -718,7 +720,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Get the list of Spanish novelists that are still alive.\n",
|
||||
"Get the list of writers that are still alive.\n",
|
||||
"A person is alive if their death date is not defined and the were born less than 100 years ago"
|
||||
]
|
||||
},
|
||||
@ -729,7 +731,7 @@
|
||||
"deletable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "2508e2f85ece2e717aa1348db290e449",
|
||||
"checksum": "7527bd597f9550ec14d454732f6b2183",
|
||||
"grade": false,
|
||||
"grade_id": "cell-474b1a72dec6827c",
|
||||
"locked": false,
|
||||
@ -739,7 +741,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%sparql https://live.dbpedia.org/sparql\n",
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||
"PREFIX dct:<http://purl.org/dc/terms/>\n",
|
||||
@ -765,7 +767,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "770bbddef5210c28486a1929e4513ada",
|
||||
"checksum": "8f8c783af97cd3024b90a8f5b7fd7027",
|
||||
"grade": true,
|
||||
"grade_id": "cell-46b62dd2856bc919",
|
||||
"locked": true,
|
||||
@ -777,7 +779,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert 'Fernando Arrabal' in solution()['columns']['nombre']\n",
|
||||
"assert 'Albert Espinosa' in solution()['columns']['nombre']\n",
|
||||
"assert 'Javier Sierra' in solution()['columns']['nombre']\n",
|
||||
"for year in solution()['columns']['nac']:\n",
|
||||
" assert int(year) >= 1918"
|
||||
]
|
||||
@ -786,7 +788,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Now, get the list of Spanish novelists that died before their fifties (i.e. younger than 50 years old), or that aren't 50 years old yet.\n",
|
||||
"Now, get the list of writers that died before their fifties (i.e. younger than 50 years old), or that aren't 50 years old yet.\n",
|
||||
"\n",
|
||||
"Hint: you can use boolean logic in your filters (e.g. `&&` and `||`).\n",
|
||||
"\n",
|
||||
@ -834,7 +836,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "18bb2d8d586bf4a5231973e69958ab75",
|
||||
"checksum": "ec821397f67619e5bfa02a19bdd597fc",
|
||||
"grade": true,
|
||||
"grade_id": "cell-461cd6ccc6c2dc79",
|
||||
"locked": true,
|
||||
@ -845,8 +847,8 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert 'Javier Sierra' in solution()['columns']['nombre']\n",
|
||||
"assert 'http://dbpedia.org/resource/Sanmao_(author)' in solution()['columns']['escritor']"
|
||||
"assert 'Wang Ruowang' in solution()['columns']['nombre']\n",
|
||||
"assert 'http://dbpedia.org/resource/Manuel_de_Pedrolo' in solution()['columns']['escritor']"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -917,7 +919,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "84ab7d64a45e03e6dd902216a2aad030",
|
||||
"checksum": "524d152d46d3c1166052b6d5871c6aa5",
|
||||
"grade": true,
|
||||
"grade_id": "cell-542e0e36347fd5d1",
|
||||
"locked": true,
|
||||
@ -928,8 +930,8 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert 'Javier Sierra' in solution()['columns']['nombre']\n",
|
||||
"assert 'http://dbpedia.org/resource/Albert_Espinosa' in solution()['columns']['escritor']\n",
|
||||
"assert 'Anna Langfus' in solution()['columns']['nombre']\n",
|
||||
"assert 'http://dbpedia.org/resource/Paul_Celan' in solution()['columns']['escritor']\n",
|
||||
"\n",
|
||||
"from collections import Counter\n",
|
||||
"c = Counter(solution()['columns']['nombre'])\n",
|
||||
@ -952,7 +954,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Get the list of living Spanish novelists born in Madrid.\n",
|
||||
"Get the list of living novelists born in Madrid.\n",
|
||||
"\n",
|
||||
"Hint: use `dbr:Madrid` and `dbo:birthPlace`"
|
||||
]
|
||||
@ -1038,7 +1040,7 @@
|
||||
"deletable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "5b9d1561a5c9786c5a803b9aaa259441",
|
||||
"checksum": "64ea2ef341901ce486bb1dcbed6c3785",
|
||||
"grade": false,
|
||||
"grade_id": "cell-e4b99af9ef91ff6f",
|
||||
"locked": false,
|
||||
@ -1062,7 +1064,7 @@
|
||||
"# YOUR ANSWER HERE\n",
|
||||
"}\n",
|
||||
"# YOUR ANSWER HERE\n",
|
||||
"LIMIT 10000"
|
||||
"LIMIT 1000"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1073,7 +1075,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "51acaeb26379c6bd2f8c767001ef79ec",
|
||||
"checksum": "fe47b48969b20b50a16a4ce4ad75e97d",
|
||||
"grade": true,
|
||||
"grade_id": "cell-68661b73c2140e4f",
|
||||
"locked": true,
|
||||
@ -1084,8 +1086,8 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert 'http://dbpedia.org/resource/A_Heart_So_White' in solution()['columns']['obra']\n",
|
||||
"assert 'http://dbpedia.org/resource/Tomorrow_in_the_Battle_Think_on_Me' in solution()['columns']['obra']\n",
|
||||
"assert 'http://dbpedia.org/resource/Cristina_Guzmán_(novel)' in solution()['columns']['obra']\n",
|
||||
"assert 'http://dbpedia.org/resource/Life_Is_a_Dream' in solution()['columns']['obra']\n",
|
||||
"assert '' in solution()['columns']['obra'] # Some authors don't have works in dbpedia"
|
||||
]
|
||||
},
|
||||
@ -1093,14 +1095,14 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Traversing the graph"
|
||||
"### Traversing the graph II"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Get a list of living Spanish novelists born in Madrid, their name in Spanish, a link to their foto and a website (if they have one).\n",
|
||||
"Get a list of writers born in Madrid, their name in Spanish, a link to their foto and a website (if they have one).\n",
|
||||
"\n",
|
||||
"If the query is right, you should see a list of writers after running the test code.\n",
|
||||
"\n",
|
||||
@ -1114,7 +1116,7 @@
|
||||
"deletable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "e3f8e18a006a763f5cdbe49c97b73f5f",
|
||||
"checksum": "d3636d90f8d6a3c824b17ce87ba6c423",
|
||||
"grade": false,
|
||||
"grade_id": "cell-b1f71c67dd71dad4",
|
||||
"locked": false,
|
||||
@ -1124,7 +1126,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%sparql http://dbpedia.org/sparql\n",
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||
"PREFIX dct:<http://purl.org/dc/terms/>\n",
|
||||
@ -1138,7 +1140,7 @@
|
||||
"# YOUR ANSWER HERE\n",
|
||||
"}\n",
|
||||
"ORDER BY ?nombre\n",
|
||||
"LIMIT 100"
|
||||
"LIMIT 5"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1204,7 +1206,8 @@
|
||||
"source": [
|
||||
"Using UNION, get a list of distinct spanish novelists AND poets.\n",
|
||||
"\n",
|
||||
"Hint: Category: Spanish_poets"
|
||||
"In this query, instead of looking for writers, try to find the right entities by looking at the `dct:subject` property.\n",
|
||||
"The entities we are looking after should be in the `Spanish_poets` and `Spanish_novelists` categories."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1214,7 +1217,7 @@
|
||||
"deletable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "9c0da379841474601397f5623abc6a9c",
|
||||
"checksum": "2547e55ac68b37687efddd50c768eb5b",
|
||||
"grade": false,
|
||||
"grade_id": "cell-21eb6323b6d0011d",
|
||||
"locked": false,
|
||||
@ -1224,7 +1227,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%sparql http://dbpedia.org/sparql\n",
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||
"PREFIX dct:<http://purl.org/dc/terms/>\n",
|
||||
@ -1238,7 +1241,7 @@
|
||||
"# YOUR ANSWER HERE\n",
|
||||
"}\n",
|
||||
"# YOUR ANSWER HERE\n",
|
||||
"LIMIT 10000"
|
||||
"LIMIT 100"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1249,7 +1252,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "f22c7db423410fcf3e8fce4ec0a8e9f9",
|
||||
"checksum": "565dac8ae632765bc3f128f830e70993",
|
||||
"grade": true,
|
||||
"grade_id": "cell-004e021e877c6ace",
|
||||
"locked": true,
|
||||
@ -1260,7 +1263,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert 'Garcilaso de la Vega' in solution()['columns']['nombre']"
|
||||
"assert 'Antonio Gala' in solution()['columns']['nombre']"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1385,7 +1388,7 @@
|
||||
"## Licence\n",
|
||||
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
|
||||
"\n",
|
||||
"© 2018 Universidad Politécnica de Madrid."
|
||||
"© 2023 Universidad Politécnica de Madrid."
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -150,7 +150,7 @@
|
||||
"deletable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "69e23e6e3dc06ca9d2b5d878c2baba94",
|
||||
"checksum": "1a23c8b9a53f7ae28f28b1c23b9706b5",
|
||||
"grade": false,
|
||||
"grade_id": "cell-ab7755944d46f9ca",
|
||||
"locked": false,
|
||||
@ -160,19 +160,19 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%sparql\n",
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||
"PREFIX dct: <http://purl.org/dc/terms/>\n",
|
||||
"PREFIX dbc: <http://dbpedia.org/resource/Category:>\n",
|
||||
"PREFIX dbo: <http://dbpedia.org/ontology/>\n",
|
||||
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n",
|
||||
"\n",
|
||||
"SELECT ?escritor, ?nombre, year(?fechaNac) as ?nac\n",
|
||||
"\n",
|
||||
"SELECT ?escritor ?nombre (year(?fechaNac) as ?nac)\n",
|
||||
"WHERE {\n",
|
||||
" ?escritor dct:subject dbc:Spanish_novelists .\n",
|
||||
" ?escritor rdfs:label ?nombre .\n",
|
||||
" ?escritor dbo:birthDate ?fechaNac .\n",
|
||||
" ?escritor dct:subject dbc:Spanish_novelists ;\n",
|
||||
" rdfs:label ?nombre ;\n",
|
||||
" dbo:birthDate ?fechaNac .\n",
|
||||
" FILTER(lang(?nombre) = \"es\") .\n",
|
||||
" # YOUR ANSWER HERE\n",
|
||||
"}\n",
|
||||
@ -188,7 +188,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "211c632634327a1fd805326fa0520cdd",
|
||||
"checksum": "e261d808f509c1e29227db94d1eab784",
|
||||
"grade": true,
|
||||
"grade_id": "cell-cf3821f2d33fb0f6",
|
||||
"locked": true,
|
||||
@ -199,8 +199,8 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert 'Camilo José Cela' in solution()['columns']['nombre']\n",
|
||||
"assert 'Javier Marías' in solution()['columns']['nombre']\n",
|
||||
"assert 'Ramiro Ledesma' in solution()['columns']['nombre']\n",
|
||||
"assert 'Ray Loriga' in solution()['columns']['nombre']\n",
|
||||
"assert all(int(x) > 1899 and int(x) < 2001 for x in solution()['columns']['nac'])"
|
||||
]
|
||||
},
|
||||
@ -304,7 +304,7 @@
|
||||
"deletable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "2a24f623c23116fd23877facb487dd16",
|
||||
"checksum": "e55173801ab36337ad356a1bc286dbd1",
|
||||
"grade": false,
|
||||
"grade_id": "cell-ceefd3c8fbd39d79",
|
||||
"locked": false,
|
||||
@ -314,7 +314,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%sparql\n",
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||
"PREFIX dct:<http://purl.org/dc/terms/>\n",
|
||||
@ -341,7 +341,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "18bb2d8d586bf4a5231973e69958ab75",
|
||||
"checksum": "1b77cfaefb8b2ec286ce7b0c70804fe0",
|
||||
"grade": true,
|
||||
"grade_id": "cell-461cd6ccc6c2dc79",
|
||||
"locked": true,
|
||||
@ -353,7 +353,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert 'Javier Sierra' in solution()['columns']['nombre']\n",
|
||||
"assert 'http://dbpedia.org/resource/Sanmao_(author)' in solution()['columns']['escritor']"
|
||||
"assert 'http://dbpedia.org/resource/José_Ángel_Mañas' in solution()['columns']['escritor']"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -392,7 +392,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%sparql\n",
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"SELECT ?localidad\n",
|
||||
"WHERE {\n",
|
||||
@ -419,7 +419,7 @@
|
||||
"deletable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "6e444c20b411033a6c45fd5a566018fa",
|
||||
"checksum": "b70a9a4f102c253e864d2e8aec79ce81",
|
||||
"grade": false,
|
||||
"grade_id": "cell-a57d3546a812f689",
|
||||
"locked": false,
|
||||
@ -429,7 +429,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%sparql\n",
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||
"PREFIX dct:<http://purl.org/dc/terms/>\n",
|
||||
@ -526,7 +526,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%sparql\n",
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||
"PREFIX dbo: <http://dbpedia.org/ontology/>\n",
|
||||
@ -535,9 +535,9 @@
|
||||
"SELECT ?com, GROUP_CONCAT(?name, \",\") as ?places # notice how we rename the variable\n",
|
||||
"\n",
|
||||
"WHERE {\n",
|
||||
" ?localidad dbo:isPartOf ?com .\n",
|
||||
" ?com dbo:type dbr:Autonomous_communities_of_Spain .\n",
|
||||
" ?localidad rdfs:label ?name .\n",
|
||||
" ?com dct:subject dbc:Autonomous_communities_of_Spain .\n",
|
||||
" ?localidad dbo:subdivision ?com ;\n",
|
||||
" rdfs:label ?name .\n",
|
||||
" FILTER (lang(?name)=\"es\")\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
@ -552,7 +552,7 @@
|
||||
"editable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "markdown",
|
||||
"checksum": "e100e2f89c832cf832add62c107e4008",
|
||||
"checksum": "4779fb61645634308d0ed01e0c88e8a4",
|
||||
"grade": false,
|
||||
"grade_id": "asdiopjasdoijasdoijasd",
|
||||
"locked": true,
|
||||
@ -561,7 +561,7 @@
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"Try it yourself, to get a list of works by each of these authors:"
|
||||
"Try it yourself, to get a list of works by each of the authors in this query:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -571,7 +571,7 @@
|
||||
"deletable": false,
|
||||
"nbgrader": {
|
||||
"cell_type": "code",
|
||||
"checksum": "9f6e26faab2be98c72fb7a917ac5a421",
|
||||
"checksum": "e5d87d1d8eba51c510241ba75981a597",
|
||||
"grade": false,
|
||||
"grade_id": "cell-2e3de17c75047652",
|
||||
"locked": false,
|
||||
@ -581,7 +581,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%sparql\n",
|
||||
"%%sparql https://dbpedia.org/sparql\n",
|
||||
"\n",
|
||||
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
|
||||
"PREFIX dct:<http://purl.org/dc/terms/>\n",
|
||||
@ -592,26 +592,17 @@
|
||||
"# YOUR ANSWER HERE\n",
|
||||
"\n",
|
||||
"WHERE {\n",
|
||||
" ?escritor dct:subject dbc:Spanish_novelists .\n",
|
||||
" ?escritor a dbo:Writer .\n",
|
||||
" ?escritor rdfs:label ?nombre .\n",
|
||||
" ?escritor dbo:birthDate ?fechaNac .\n",
|
||||
" ?escritor dbo:birthPlace dbr:Madrid .\n",
|
||||
" OPTIONAL {\n",
|
||||
" ?obra dbo:author ?escritor .\n",
|
||||
" ?obra rdfs:label ?titulo .\n",
|
||||
" }\n",
|
||||
" OPTIONAL {\n",
|
||||
" ?escritor dbo:deathDate ?fechaDef .\n",
|
||||
" }\n",
|
||||
" FILTER (?fechaNac <= \"2000\"^^xsd:date).\n",
|
||||
" FILTER (?fechaNac >= \"1918\"^^xsd:date).\n",
|
||||
" FILTER (!bound(?fechaDef) || (?fechaNac >= \"1918\"^^xsd:date)) .\n",
|
||||
" # YOUR ANSWER HERE\n",
|
||||
" FILTER(lang(?nombre) = \"es\") .\n",
|
||||
" FILTER(!bound(?titulo) || lang(?titulo) = \"en\") .\n",
|
||||
"\n",
|
||||
"}\n",
|
||||
"ORDER BY ?nombre\n",
|
||||
"LIMIT 10000"
|
||||
"LIMIT 100"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -639,7 +630,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@ -653,7 +644,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.1"
|
||||
"version": "3.8.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
@ -37,7 +37,7 @@ def send_query(query, endpoint):
|
||||
context.check_hostname = False
|
||||
context.verify_mode = ssl.CERT_NONE
|
||||
|
||||
res = urlopen(r, context=context)
|
||||
res = urlopen(r, context=context, timeout=2)
|
||||
data = res.read().decode('utf-8')
|
||||
if res.getcode() == 200:
|
||||
try:
|
||||
|
0
lod/tests.py
Normal file
0
lod/tests.py
Normal file
Loading…
Reference in New Issue
Block a user