Skip to content

Commit 3716825

Browse files
authored
Merge pull request #3492 from programminghistorian/Issue-3491
Issue-3491-intro-linked-data
2 parents 4e16d61 + a630316 commit 3716825

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

en/lessons/intro-to-linked-data.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ reviewers:
88
editors:
99
- Adam Crymble
1010
date: 2017-05-07
11+
lesson-testers: David Valentine
12+
tested_date: 2025-02-28
1113
layout: lesson
1214
difficulty: 1
1315
review-ticket: https://github.com/programminghistorian/ph-submissions/issues/33
@@ -216,15 +218,15 @@ Turtle uses aliases or a shortcuts known as [prefixes](https://www.w3.org/TeamSu
216218

217219
We don't want to type this out every time we refer to this person (Jack Straw, you'll remember). So we just have to announce our shortcut:
218220

219-
@prefix toby: <http://data.history.ac.uk/tobias-project/person> .
221+
@prefix toby: <http://data.history.ac.uk/tobias-project/person/> .
220222

221223
Then Jack is `toby:15601`, which replaces the long URI and is easier on the eye. I have chosen 'toby', but could just as easily chosen any string of letters.
222224

223225
Let's now move from Jack Straw to William Shakespeare and use Turtle to describe some stuff about his works. We'll need to decide on the authority files to use, a process which, as mentioned above, is best gleaned from looking at other LOD sets. Here we'll use [Dublin Core](https://en.wikipedia.org/wiki/Dublin_Core), a library [metadata](https://en.wikipedia.org/wiki/Metadata) standard, as one of our prefixes, the [Library of Congress Control Number](https://en.wikipedia.org/wiki/Library_of_Congress_Control_Number) authority file for another, and the last one (VIAF) should be familiar to you. Together these three authority files provide unique identifiers for all of the entities I plan to use in this example.:
224226

225-
@prefix lccn: <http://id.loc.gov/authorities/names> .
227+
@prefix lccn: <http://id.loc.gov/authorities/names/> .
226228
@prefix dc: <http://purl.org/dc/elements/1.1/> .
227-
@prefix viaf: <http://viaf.org/viaf> .
229+
@prefix viaf: <http://viaf.org/viaf/> .
228230

229231
lccn:n82011242 dc:creator viaf:96994048 .
230232

@@ -234,9 +236,9 @@ In the above example, lccn:n82011242 represents Macbeth; dc:creator links Macbet
234236

235237
Turtle also allows you to list triples without bothering to repeat each URI when you've only just used it. Let's add the date when scholars think Macbeth was written, using the Dublin Core attribute-value pair: `dc:created 'YYYY'`:
236238

237-
@prefix lccn: <http://id.loc.gov/authorities/names> .
239+
@prefix lccn: <http://id.loc.gov/authorities/names/> .
238240
@prefix dc: <http://purl.org/dc/elements/1.1/> .
239-
@prefix viaf: <http://viaf.org/viaf> .
241+
@prefix viaf: <http://viaf.org/viaf/> .
240242

241243
lccn:n82011242 dc:creator viaf:96994048 ;
242244
dc:created "1606" .
@@ -313,11 +315,11 @@ If you're familiar with XML this will be like mother's milk to you. If you're no
313315

314316
For this final section we will interrogate some LOD and see what you can do with it.
315317

316-
The query language we use for LOD is called [SPARQL](https://en.wikipedia.org/wiki/SPARQL). It's one of those recursive acronyms beloved of techie people: *SPARQL Protocol and Query Language*.
318+
The query language we use for LOD is called [SPARQL](https://en.wikipedia.org/wiki/SPARQL). It's one of those recursive acronyms beloved of techie people: *SPARQL Protocol and RDF Query Language*.
317319

318320
As I mentioned at the beginning, *Programming Historian* has [a complete lesson](/lessons/graph-databases-and-SPARQL), by Matthew Lincoln, on using SPARQL. My final section here is just an overview of the basic concepts, and if SPARQL piques your interest, you can get a thorough grounding from Lincoln's tutorial.
319321

320-
We're going to run our SPARQL queries on [DBpedia](https://en.wikipedia.org/wiki/SPARQL), which is a huge LOD set derived from Wikipedia. As well as being full of information that is very difficult to find through the usual Wikipedia interface, it has several SPARQL "end points" - interfaces where you can type in SPARQL queries and get results from DBpedia's triples.
322+
We're going to run our SPARQL queries on [DBpedia](https://en.wikipedia.org/wiki/DBpedia), which is a huge LOD set derived from Wikipedia. As well as being full of information that is very difficult to find through the usual Wikipedia interface, it has several SPARQL "end points" - interfaces where you can type in SPARQL queries and get results from DBpedia's triples.
321323

322324
The SPARQL query end point I use is called [snorql](http://dbpedia.org/snorql/). These end points occasionally seem to go offline, so if that should be the case, try searching for *dbpedia sparql* and you should find a similar replacement.
323325

@@ -341,15 +343,15 @@ Let's start with something simple to see how this works. Paste (or, better, type
341343
:Lyndal_Roper ?b ?c
342344
}
343345

344-
Hit 'go' and, if you left the drop-down box as 'browse' you should get two columns labelled "b" and "c". (Note that here, searching for a string, case does matter: lyndal_roper will get you no results.)
346+
Hit 'go' and, if you left the drop-down box as 'browse' you should get two columns labelled "b" and "c". (Note that here, case does matter: lyndal_roper will get you no results.)
345347

346348
{% include figure.html filename="en-or-intro-to-linked-data-04.png" caption="Figure 4. Top of results lists for a query for all triples with 'Lyndal_Roper' as subject." %}
347349

348350
So what just happened? And how did I know what to type?
349351

350352
I didn't, really, and that is one of the issues with SPARQL end points. When getting to know a dataset you have to try things and find out what terms are used. Because this comes from *Wikipedia*, and I was interested in what information on historians I could find, I went to the *Wikipedia* page for the historian [Lyndal Roper](https://en.wikipedia.org/wiki/Lyndal_Roper).
351353

352-
The part at the end of the URL is `Lyndal_Roper` and I concluded that this string is likely to be how Roper is referred to in DBpedia. Because I don't know what else might be in triples that mention Roper I use `?a` and `?b`: these are just place-holders: I could equally well have typed `?whatever` and `?you_like` and the columns would have had those headings. When you want to be more precise about what you are returning, it will be more important to label columns meaningfully.
354+
The part at the end of the URL is `Lyndal_Roper` and I concluded that this string is likely to be how Roper is referred to in DBpedia. Because I don't know what else might be in triples that mention Roper I use `?b` and `?c`: these are just place-holders: I could equally well have typed `?whatever` and `?you_like` and the columns would have had those headings. When you want to be more precise about what you are returning, it will be more important to label columns meaningfully.
353355

354356
Try your own SPARQL query now: choose a *Wikipedia* page and copy the end part of the URL, after the final slash, and put it in place of Lyndal\_Roper. Then hit 'go'.
355357

@@ -373,7 +375,7 @@ Run the query. Does it work for you? I get a big list of historians.
373375

374376
{% include figure.html filename="en-or-intro-to-linked-data-05.png" caption="Figure 5. Historians, according to DBpedia." %}
375377

376-
So this works for creating lists, which is useful, but it would much more powerful to combine lists, to get intersections of sests. I found a couple more things that might be interesting to query in Lyndal Roper's DBpedia attributes: <http://dbpedia.org/class/yago/WikicatBritishHistorians> and <http://dbpedia.org/class/yago/WikicatWomenHistorians>. It's very easy to combine these by asking a for a variable to be returned (in our case this is `?name`) and then using that in multiple lines of a query. Note as well the space and full point at the end of the first line beginning with `?name`:
378+
So this works for creating lists, which is useful, but it would much more powerful to combine lists, to get intersections of sests. I found a couple more things that might be interesting to query in Lyndal Roper's DBpedia attributes: <http://dbpedia.org/class/yago/WikicatBritishHistorians> and <http://dbpedia.org/class/yago/WikicatWomenHistorians>. It's very easy to combine these by asking for a variable to be returned (in our case this is `?name`) and then using that in multiple lines of a query. Note as well the space and full point at the end of the first line beginning with `?name`:
377379

378380
SELECT ?name
379381
WHERE {

es/lecciones/introduccion-datos-abiertos-enlazados.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ translation-editor:
1616
translation-reviewer:
1717
- Maria Jose Afanador
1818
- Antonio Rojas Castro
19+
lesson-testers: David Valentine
20+
tested_date: 2025-02-28
1921
review-ticket: https://github.com/programminghistorian/ph-submissions/issues/142
2022
original: intro-to-linked-data
2123
layout: lesson
@@ -213,15 +215,15 @@ Turtle usa alias o atajos conocidos como [prefijos](https://www.w3.org/TeamSubmi
213215

214216
No queremos escribir esto cada vez que nos referimos a esta persona (Jack Straw, como recordarás). Entonces sólo tenemos que anunciar nuestro atajo:
215217

216-
@prefix toby: <http://data.history.ac.uk/tobias-project/person> .
218+
@prefix toby: <http://data.history.ac.uk/tobias-project/person/> .
217219

218220
Así, Jack es `toby:15601`, que reemplaza el URI largo y es más fácil de leer. He elegido 'toby', pero podría haber elegido cualquier cadena de letras con la misma facilidad.
219221

220222
Pasemos ahora de Jack Straw a William Shakespeare y usemos Turtle para describir algunos elementos sobre sus obras. Tendremos que decidir qué archivos de autoridad usar, un proceso que, como se mencionó anteriormente, se optimiza si consultamos otros conjuntos de LOD. Aquí usaremos [Dublin Core](https://es.wikipedia.org/wiki/Dublin_Core), un estándar de [metadatos](https://es.wikipedia.org/wiki/Metadato) usado por las bibliotecas, como uno de nuestros prefijos, el archivo de autoridad del [Número de control de la Biblioteca del Congreso](https://es.wikipedia.org/wiki/Library_of_Congress_Control_Number) para otro, y el último (VIAF) debería serte familiar. En conjunto, estos tres archivos de autoridad proporcionan identificadores únicos para todas las entidades que planeo usar en este ejemplo:
221223

222-
@prefix lccn: <http://id.loc.gov/authorities/names> .
224+
@prefix lccn: <http://id.loc.gov/authorities/names/> .
223225
@prefix dc: <http://purl.org/dc/elements/1.1/> .
224-
@prefix viaf: <http://viaf.org/viaf> .
226+
@prefix viaf: <http://viaf.org/viaf/> .
225227

226228
lccn:n82011242 dc:creator viaf:96994048 .
227229

@@ -231,9 +233,9 @@ En el ejemplo anterior, lccn: n82011242 representa a Macbeth; dc: creator vincul
231233

232234
Turtle también te permite listar tripletas sin molestarte en repetir cada URI cuando acabas de usarlo. Agreguemos la fecha en la que los expertos creen que Macbeth fue escrita utilizando el par atributo-valor de Dublin Core:`dc: created 'YYYY'` :
233235

234-
@prefix lccn: <http://id.loc.gov/authorities/names> .
236+
@prefix lccn: <http://id.loc.gov/authorities/names/> .
235237
@prefix dc: <http://purl.org/dc/elements/1.1/> .
236-
@prefix viaf: <http://viaf.org/viaf> .
238+
@prefix viaf: <http://viaf.org/viaf/> .
237239
lccn: n82011242 dc: creator viaf: 96994048 ;
238240
dc: created "1606" .
239241

@@ -304,11 +306,11 @@ Si estás familiarizado con XML, esto será muy fácil para ti. Si no lo estás,
304306

305307
Para esta sección final, interrogaremos algunos LOD y veremos qué podemos hacer con ellos.
306308

307-
El lenguaje de consulta que utilizamos para los LOD se llama [SPARQL](https://es.wikipedia.org/wiki/SPARQL). Es uno de esos acrónimos recursivos amados por los tecnólogos: *Protocolo y lenguaje de consulta SPARQL* .
309+
El lenguaje de consulta que utilizamos para los LOD se llama [SPARQL](https://es.wikipedia.org/wiki/SPARQL). Es uno de esos acrónimos recursivos amados por los tecnólogos: *Protocolo SPARQL y lenguaje de consulta RDF*.
308310

309311
Como mencioné al principio, *The Programming Historian en español* tiene [una lección completa](/es/lecciones/sparql-datos-abiertos-enlazados), por Matthew Lincoln, sobre el uso de SPARQL. Esta última sección sólo proporciona una descripción general de los conceptos básicos y, si SPARQL despierta tu interés, puedes obtener una base sólida con el tutorial de Lincoln.
310312

311-
Vamos a ejecutar nuestras consultas SPARQL en [DBpedia](https://es.wikipedia.org/wiki/SPARQL), que es un gran conjunto de LOD derivado de Wikipedia. Además de estar lleno de información que es muy difícil de encontrar a través de la interfaz habitual de Wikipedia, tiene varios "puntos finales" SPARQL: interfaces donde puedes escribir consultas SPARQL y obtener resultados de las tripletas de DBpedia.
313+
Vamos a ejecutar nuestras consultas SPARQL en [DBpedia](https://es.wikipedia.org/wiki/DBpedia), que es un gran conjunto de LOD derivado de Wikipedia. Además de estar lleno de información que es muy difícil de encontrar a través de la interfaz habitual de Wikipedia, tiene varios "puntos finales" SPARQL: interfaces donde puedes escribir consultas SPARQL y obtener resultados de las tripletas de DBpedia.
312314

313315
El punto de entrada (*endpoint*) de consulta SPARQL que yo uso se llama [snorql](http://dbpedia.org/snorql/). Estos puntos de entrada a veces parecen desconectarse, por lo que, si ese fuera el caso, busca *dbpedia sparql* en internet para encontrar un reemplazo similar.
314316

@@ -331,15 +333,15 @@ Comencemos con algo simple para ver cómo funciona esto. Pega esto (o, mejor, es
331333
:Lyndal_Roper ?b ?c
332334
}
333335

334-
Haz clic en "Go!"(ir) y, si dejaste el cuadro desplegable como "Browse" (navegar), deberías obtener dos columnas con la etiqueta "b" y "c". (Ten en cuenta que aquí, buscando una cadena, las mayúsculas y minúsculas sí importan: lyndal_roper no te dará ningún resultado).
336+
Haz clic en "Go!"(ir) y, si dejaste el cuadro desplegable como "Browse" (navegar), deberías obtener dos columnas con la etiqueta "b" y "c". (Ten en cuenta que aquí, las mayúsculas y minúsculas sí importan: lyndal_roper no te dará ningún resultado).
335337

336338
{% include figure.html filename="en-or-intro-to-linked-data-04.png" caption="Figura 4. Parte inicial de la lista de resultados de una consulta para todas las tripletas con 'Lyndal_Roper' como sujeto." %}
337339

338340
Recapitulando, ¿qué acaba de pasar? ¿Y cómo sé qué escribir?
339341

340342
En realidad no lo sabía y ese es uno de los problemas con los puntos de entrada SPARQL. Al conocer un conjunto de datos, debes probar y descubrir qué términos se usan. Como este proviene de Wikipedia y me interesaba saber qué información sobre historiadores podía encontrar, fui a la página de Wikipedia del historiador [Lyndal Roper](https://en.wikipedia.org/wiki/Lyndal_Roper).
341343

342-
La parte al final de la URL es `Lyndal_Roper` y llegué a la conclusión de que esta cadena es probablemente la forma en que se hace referencia a Roper en DBpedia. Como no sé qué más podría haber en las tripletas que mencionen a Roper, usé `?a` y `?b`. Estos son comodines: podría haber escrito igualmente `?en_cualquier_sitio` y `?como_gustes` y las columnas tendrían esos títulos. Cuando desees ser más preciso sobre lo que estás obteniendo, será más importante etiquetar las columnas de forma significativa.
344+
La parte al final de la URL es `Lyndal_Roper` y llegué a la conclusión de que esta cadena es probablemente la forma en que se hace referencia a Roper en DBpedia. Como no sé qué más podría haber en las tripletas que mencionen a Roper, usé `?b` y `?c`. Estos son comodines: podría haber escrito igualmente `?en_cualquier_sitio` y `?como_gustes` y las columnas tendrían esos títulos. Cuando desees ser más preciso sobre lo que estás obteniendo, será más importante etiquetar las columnas de forma significativa.
343345

344346
Prueba ahora tu propia consulta SPARQL ahora: elije una página de Wikipedia y copia la parte final de la URL, lo que aparece después de la barra diagonal final, y colócalo en lugar de Lyndal_Roper. Luego presiona 'Go!'.
345347

0 commit comments

Comments
 (0)