Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes...

26
Introducció a Introducció a SPARQL a partir de SPARQL a partir de Wikidata Wikidata Toni Hermoso Pulido @Toniher Amical Wikimedia https://w.wiki/Bw$

Transcript of Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes...

Page 1: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

Introducció aIntroducció aSPARQL a partir deSPARQL a partir de

WikidataWikidata

Toni Hermoso Pulido@Toniher

Amical Wikimedia

https://w.wiki/Bw$

Page 2: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SSPARQL PARQL PProtocolrotocol

AAndnd

RRDF DF QQuery uery LLanguageanguage

SPARQLSPARQL

Page 3: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

RResource esource DDescriptionescriptionFFrameworkramework

RDFRDF

Page 4: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

TriplesTriples

Page 5: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

Serialització RDFSerialització RDFElements de WikidataElements de Wikidata

Documentació aMediaWiki

JSON:

XML/RDF:

Turtle/RDF:

etc.

https://www.wikidata.org/wiki/Special:EntityData/Q1492.json

https://www.wikidata.org/wiki/Special:EntityData/Q1492.rdf

https://www.wikidata.org/wiki/Special:EntityData/Q1492.ttl

Accés de dades aWikidata

Page 6: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#GatsSELECT ?itemWHERE { ?item wdt:P31 wd:Q146 .}

123456

https://query.wikidata.org/

Page 7: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQLhttps://query.wikidata.org/

wdt: Propertieswd: Entities

...others:

rdfsschema

PREFIXESPREFIXES

Page 8: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#GatsSELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q146 . ?item rdfs:label ?itemLabel .}

1234567

 https://w.wiki/Buw

Page 9: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#GatsSELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q146 ; rdfs:label ?itemLabel .}

1234567

https://w.wiki/Buy

Page 10: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#GatsSELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q146 ; rdfs:label ?itemLabel . FILTER(LANG(?itemLabel) = "ca").}

12345678

https://w.wiki/Buz

Page 11: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#GatsSELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q146 . SERVICE wikibase:label { bd:serviceParam wikibase:language "ca". }}

123456789

1011

https://w.wiki/Bu$

Page 12: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#GatsSELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q146 . SERVICE wikibase:label { bd:serviceParam wikibase:language "es,fr,ca". }}ORDER BY ?itemLabelLIMIT 10

123456789

101112

https://w.wiki/Bv2

Page 13: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#Matemàtiques i polítiques SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5; wdt:P106 wd:Q170790, wd:Q82955; rdfs:label ?itemLabel . ?item wdt:P21 wd:Q6581072 .}

12345678

https://w.wiki/Bv5

Page 14: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#Matemàtiques i polítiques SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5; wdt:P106 wd:Q170790, wd:Q82955; rdfs:label ?itemLabel . ?item wdt:P21 wd:Q6581072 . FILTER(LANG(?itemLabel) = "ca") . }

123456789

https://w.wiki/Bv6

Page 15: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#Matemàtiques i polítiques SELECT ?item ?itemLabel ?itemDescription WHERE { ?item wdt:P31 wd:Q5; wdt:P106 wd:Q170790, wd:Q82955; rdfs:label ?itemLabel ; schema:description ?itemDescription . ?item wdt:P21 wd:Q6581072 . FILTER(LANG(?itemLabel) = "ca") . FILTER(LANG(?itemDescription) = "ca") . }

123456789101112

https://w.wiki/Bv7

Page 16: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#Matemàtiques i polítiques SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5; wdt:P106 wd:Q170790, wd:Q82955 . ?item wdt:P21 wd:Q6581072 . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca". }}

123456789

1011

https://w.wiki/Bv8

Page 17: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#Matemàtiques i polítiques amb imatges SELECT DISTINCT ?item ?itemLabel ?image WHERE { ?item wdt:P31 wd:Q5; wdt:P106 wd:Q170790, wd:Q82955 . ?item wdt:P21 wd:Q6581072 . ?item wdt:P18 ?image . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca". }}

123456789

101112

https://w.wiki/Bv9

Page 18: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL#Matemàtiques i polítiques amb imatges opcionals SELECT DISTINCT ?item ?itemLabel ?image WHERE { ?item wdt:P31 wd:Q5; wdt:P106 wd:Q170790, wd:Q82955 . ?item wdt:P21 wd:Q6581072 . OPTIONAL { ?item wdt:P18 ?image . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca". }}

123456789

1011121314

https://w.wiki/BvC

Page 19: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#Matemàtiques i polítiques només amb imatges SELECT DISTINCT ?item ?itemLabel ?image WHERE { ?item wdt:P31 wd:Q5; wdt:P106 wd:Q170790, wd:Q82955 . ?item wdt:P21 wd:Q6581072 . FILTER EXISTS { ?item wdt:P18 ?image . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca". }}

123456789

1011121314

https://w.wiki/BvD

Page 20: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQL

#Matemàtiques i polítiques sense imatgesSELECT DISTINCT ?item ?itemLabel ?image WHERE { ?item wdt:P31 wd:Q5; wdt:P106 wd:Q170790, wd:Q82955 . ?item wdt:P21 wd:Q6581072 . FILTER NOT EXISTS { ?item wdt:P18 ?image . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca". }}

123456789

10111213

https://w.wiki/BvE

Page 21: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQLhttps://w.wiki/BvH

#Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE { ?item wdt:P31 wd:Q5; wdt:P106 wd:Q170790, wd:Q82955 . ?item wdt:P21 wd:Q6581072 ; wdt:P569 ?born . FILTER (?born >= "1961-01-01T00:00:00Z"^^xsd:dateTime) . OPTIONAL { ?item wdt:P18 ?image . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca". }}

1234567891011121314151617

Page 22: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQLhttps://w.wiki/BvJ

# Subclasses de matemàtic SELECT DISTINCT ?item ?itemLabel WHERE { ?item wdt:P279* wd:Q170790; SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca". }}

12345678

Page 23: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQLhttps://w.wiki/BvL

#Matemàtiques (ampli) amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?born ?image WHERE { ?item wdt:P31 wd:Q5; wdt:P106/wdt:P279* wd:Q170790; wdt:P21 wd:Q6581072; wdt:P569 ?born. FILTER(?born >= "1961-01-01T00:00:00Z"^^xsd:dateTime) OPTIONAL { ?item wdt:P18 ?image. } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca". }}

123456789

1011121314

Page 24: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQLhttps://w.wiki/BvM

#Matemàtiques (ampli) amb imatges opcionals #nascudes després del 1961 i amb lloc de naixement conegut SELECT DISTINCT ?item ?born ?birthPlace ?image WHERE { ?item wdt:P31 wd:Q5; wdt:P106/wdt:P279* wd:Q170790; wdt:P21 wd:Q6581072; wdt:P569 ?born ; wdt:P19 ?birthPlace . FILTER(?born >= "1961-01-01T00:00:00Z"^^xsd:dateTime) OPTIONAL { ?item wdt:P18 ?image. } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca". }}

123456789

101112131415

Page 25: Wikidata · 2019-11-12 · SPARQL #Matemàtiques i polítiques amb imatges opcionals #nascudes després del 1961 SELECT DISTINCT ?item ?itemLabel ?born ?image WHERE {?item wdt:P31

SPARQLSPARQLhttps://w.wiki/BvN

#Matemàtiques (ampli) amb imatges opcionals #nascudes després del 1961 i amb lloc de naixement conegut SELECT DISTINCT ?item ?born ?birthPlace ?coordinate ?image WHERE { ?item wdt:P31 wd:Q5; wdt:P106/wdt:P279* wd:Q170790; wdt:P21 wd:Q6581072; wdt:P569 ?born ; wdt:P19 ?birthPlace . ?birthPlace wdt:P625 ?coordinate . FILTER(?born >= "1961-01-01T00:00:00Z"^^xsd:dateTime) OPTIONAL { ?item wdt:P18 ?image. } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca". }}

123456789

10111213141516