-- Wikidata Example 1
SPARQL
PREFIX wd:
PREFIX wdt:
PREFIX wikibase:
PREFIX p:
PREFIX ps:
PREFIX pq:
PREFIX rdfs:
PREFIX bd:
PREFIX hint:
SELECT *
WHERE {
SERVICE
{ SELECT DISTINCT ?item ?label ?numero (SAMPLE(?image) AS ?image)
WHERE {
?item p:P528 ?catalogStatement .
?item rdfs:label ?label .
?catalogStatement ps:P528 ?numero .
?catalogStatement pq:P972 wd:Q14530 .
OPTIONAL {?item wdt:P18 ?image } .
# SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
GROUP BY ?item ?label ?numero ORDER BY ?numero
}
} ;
-- Live Results Link: https://tinyurl.com/khm8dzt
-- Wikidata & DBpedia Example 2
SPARQL
PREFIX wd:
PREFIX wdt:
PREFIX wikibase:
PREFIX p:
PREFIX ps:
PREFIX pq:
PREFIX rdfs:
PREFIX bd:
PREFIX dct:
SELECT DISTINCT xsd:string(?label) as ?name?dbpediaID ?item as ?wikidataID
?description
WHERE {
SERVICE
{
SELECT DISTINCT ?item ?numero (SAMPLE(?pic) AS ?picture)
WHERE {
?item p:P528 ?catalogStatement .
?catalogStatement ps:P528 ?numero .
?catalogStatement pq:P972 wd:Q14530 .
OPTIONAL {?item wdt:P18 ?pic } .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
GROUP BY ?item ?numero ORDER BY ?numero
}
SERVICE
{
SELECT DISTINCT ?item ?dbpediaID ?label ?image ?description ?subjectText
FROM
WHERE { ?dbpediaID owl:sameAs ?item ;
rdfs:label ?label ;
foaf:depiction ?image ;
rdfs:comment ?description ;
dct:subject [ rdfs:label ?subjectText ] .
FILTER (LANG(?label) = "en")
FILTER (LANG(?description) = "en")
}
}
} ;
-- Live Results Link: https://tinyurl.com/k475m7u
--- Federated Query Across DBpedia and Wikidata SPARQL Query Endpoints for PivotViewer
SPARQL
PREFIX wd:
PREFIX wdt:
PREFIX wikibase:
PREFIX p:
PREFIX ps:
PREFIX pq:
PREFIX rdfs:
PREFIX bd:
PREFIX dct:
SELECT DISTINCT ?subjectText ?dbpediaID as ?href xsd:string(?label) as ?name
?description ?item as ?wikidataID ?dbpediaID ?image ?picture
WHERE {
SERVICE
{
SELECT DISTINCT ?item ?numero (SAMPLE(?pic) AS ?picture)
WHERE {
?item p:P528 ?catalogStatement .
?catalogStatement ps:P528 ?numero .
?catalogStatement pq:P972 wd:Q14530 .
OPTIONAL {?item wdt:P18 ?pic } .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
GROUP BY ?item ?numero ORDER BY ?numero
}
SERVICE
{
SELECT DISTINCT ?item ?dbpediaID ?label ?image ?description ?subjectText
FROM
WHERE { ?dbpediaID owl:sameAs ?item ;
rdfs:label ?label ;
foaf:depiction ?image ;
rdfs:comment ?description ;
dct:subject [ rdfs:label ?subjectText ] .
FILTER (LANG(?label) = "en")
FILTER (LANG(?description) = "en")
}
}
} ;
-- Live Result Link: https://tinyurl.com/m4e77nz
-- Adds Names of Entity Types for additional Categorization
SPARQL
PREFIX wd:
PREFIX wdt:
PREFIX wikibase:
PREFIX p:
PREFIX ps:
PREFIX pq:
PREFIX rdfs:
PREFIX bd:
PREFIX dct:
SELECT DISTINCT ?dbpediaID as ?href xsd:string(?label) as ?name
?description ?subjectText ?typeName
?item as ?wikidataID ?dbpediaID ?image ?picture
WHERE {
SERVICE
{
SELECT DISTINCT ?item ?numero (SAMPLE(?pic) AS ?picture)
WHERE {
?item p:P528 ?catalogStatement .
?catalogStatement ps:P528 ?numero .
?catalogStatement pq:P972 wd:Q14530 .
OPTIONAL {?item wdt:P18 ?pic } .
# SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
GROUP BY ?item ?numero ORDER BY ?numero
}
SERVICE
{
SELECT ?item ?dbpediaID ?label ?image ?description ?subjectText ?typeName
FROM
WHERE { ?dbpediaID a [rdfs:label ?typeName] ;
owl:sameAs ?item ;
rdfs:label ?label ;
foaf:depiction ?image;
rdfs:comment ?description ;
dct:subject [ rdfs:label ?subjectText ] .
FILTER (LANG(?label) = "en")
FILTER (LANG(?typeName) = "en")
FILTER (LANG(?description) = "en")
}
}
} ;
-- Live Results Link : https://tinyurl.com/lw3nc3y
-- Saint-Raymond Museum
-- Shows Empty Solution fields due to missing data in DBpedia
SPARQL
PREFIX wd:
PREFIX wdt:
PREFIX wikibase:
PREFIX p:
PREFIX ps:
PREFIX pq:
PREFIX rdfs:
PREFIX bd:
PREFIX dct:
SELECT DISTINCT ?dbpediaID as ?href xsd:string(?label) as ?name
?description ?subjectText
?item as ?wikidataID ?dbpediaID ?img ?image
WHERE {
SERVICE
{
SELECT DISTINCT ?item ?monarque ?image
(CONCAT("http://zone47.com/crotos/?p195=19675&p180=", REPLACE( str(?monarque),"http://www.wikidata.org/entity/Q","")) as ?voir )
WHERE {
?item wdt:P195 wd:Q1376.
?item wdt:P180 ?monarque .
?monarque wdt:P39 wd:Q842606 .
OPTIONAL{ ?item wdt:P18 ?image }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" }
}
}
SERVICE
{
SELECT ?item ?dbpediaID ?label ?img ?description ?subjectText
FROM
WHERE {
OPTIONAL { ?dbpediaID owl:sameAs ?item ;
rdfs:label ?label ;
foaf:depiction ?img;
rdfs:comment ?description ;
dct:subject [ rdfs:label ?subjectText ] .
FILTER (LANG(?label) = "en")
FILTER (LANG(?typeName) = "en")
FILTER (LANG(?description) = "en")
}
}
}
} ;
-- Live Results Link: https://tinyurl.com/keb5oyk
-- Tennis
SPARQL
PREFIX wd:
PREFIX wdt:
PREFIX wikibase:
PREFIX p:
PREFIX ps:
PREFIX pq:
PREFIX rdfs:
PREFIX bd:
SELECT *
WHERE {
SERVICE {
SELECT ?singlesEvent ?singlesEventLabel ?wimbledonEvent ?wimbledonEventLabel
?date ?winnerItem ?Player_name ?Event ?image ?Playing_Hand ?Country ?enArticle
(COUNT(?article) as ?rank)
WHERE {
VALUES ?events {wd:Q16893072 wd:Q16893403}
?singlesEvent wdt:P31 ?events .
?singlesEvent wdt:P361 ?wimbledonEvent .
?wimbledonEvent wdt:P31 wd:Q41520 .
?wimbledonEvent wdt:P582 ?endDate .
?singlesEvent wdt:P1346 ?winnerItem .
?winnerItem wdt:P21 ?genderItem .
OPTIONAL{?winnerItem wdt:P741 ?playingHandItem }
OPTIONAL{?winnerItem wdt:P27 ?citizenshipItem }
BIND (if(?genderItem = wd:Q6581072, ?endDate - "P1D"^^xsd:duration, ?endDate ) as ?date )
BIND (if(?genderItem = wd:Q6581072, "Women's Singles", "Men's Singles") as ?Event)
OPTIONAL {?winnerItem wdt:P18 ?image }
OPTIONAL {?article schema:about ?winnerItem }
OPTIONAL {?enArticle schema:about ?winnerItem .
?enArticle schema:isPartOf
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
?wimbledonEvent rdfs:label ?wimbledonEventLabel .
?singlesEvent rdfs:label ?singlesEventLabel .
?winnerItem rdfs:label ?Player_name .
?playingHandItem rdfs:label ?Playing_Hand .
?citizenshipItem rdfs:label ?Country .}
}
GROUP BY ?singlesEvent ?singlesEventLabel ?wimbledonEvent ?wimbledonEventLabel ?date
?winnerItem ?Player_name ?Event ?image ?Playing_Hand ?Country ?enArticle
ORDER BY DESC (?rank)
}
SERVICE
{
SELECT ?singlesEvent ?dbpediaEventID ?dbpediaWimbledonEventID ?wimbledonEvent
FROM
WHERE {
OPTIONAL { ?dbpediaEventID owl:sameAs ?singlesEvent .
?dbpediaWimbledonEventID owl:sameAs ?wimbledonEvent .
# rdfs:label ?label ;
# foaf:depiction ?img;
# rdfs:comment ?description ;
# dct:subject [ rdfs:label ?subjectText ] .
# FILTER (LANG(?label) = "en")
# FILTER (LANG(?typeName) = "en")
# FILTER (LANG(?description) = "en")
}
}
}
} ;
-- Live Results Link: https://tinyurl.com/k3n7o2g
-- Europeana
SPARQL
PREFIX wd:
PREFIX wdt:
PREFIX wikibase:
PREFIX p:
PREFIX ps:
PREFIX pq:
PREFIX psv:
PREFIX rdfs:
PREFIX bd:
SELECT ?work ?dbpediaWorkID ?title ?inception ?precision
?image ?Exhibition_country ?type_of_work
?creator ?genre ?depicting ?material_used
WHERE {
SERVICE {
SELECT ?work ?title ?inception ?precision
?image ?Exhibition_country ?type_of_work
?creator ?genre ?depicting ?material_used
WHERE {
{
SELECT ?work ?inception ?precision ?exhibitionCountryItem
?instanceOfItem ?creatorItem ?genreItem ?depictingItem
?materialUsedItem (SAMPLE(?image) as ?image) (COUNT(?article) as ?rank)
WHERE {
?work wdt:P608 wd:Q20980830.
FILTER (?work != wd:Q133575)
?work p:P608/pq:P17 ?exhibitionCountryItem.
?work p:P571/psv:P571 ?inceptionStatementNode .
?inceptionStatementNode wikibase:timeValue ?inception .
?inceptionStatementNode wikibase:timePrecision ?precision .
OPTIONAL {?work wdt:P18 ?image}
OPTIONAL {?article schema:about ?work}
OPTIONAL {?work wdt:P31 ?instanceOfItem }
OPTIONAL {?work wdt:P170 ?creatorItem }
OPTIONAL {?work wdt:P136 ?genreItem }
OPTIONAL {?work wdt:P180 ?depictingItem }
OPTIONAL {?work wdt:P186 ?materialUsedItem }
}
GROUP BY ?work ?inception ?precision ?exhibitionCountryItem ?instanceOfItem
?creatorItem ?genreItem ?depictingItem ?materialUsedItem
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language 'en' .
?work rdfs:label ?title .
?instanceOfItem rdfs:label ?type_of_work .
?creatorItem rdfs:label ?creator .
?genreItem rdfs:label ?genre .
?depictingItem rdfs:label ?depicting .
?materialUsedItem rdfs:label ?material_used .
?exhibitionCountryItem rdfs:label ?Exhibition_country .
}
}
ORDER BY DESC (?rank)
}
SERVICE
{
SELECT ?work ?dbpediaWorkID
FROM
WHERE {
OPTIONAL { ?dbpediaWorkID owl:sameAs ?work .
# rdfs:label ?label ;
# foaf:depiction ?img;
# rdfs:comment ?description ;
# dct:subject [ rdfs:label ?subjectText ] .
# FILTER (LANG(?label) = "en")
# FILTER (LANG(?typeName) = "en")
# FILTER (LANG(?description) = "en")
}
}
}
} ;
-- Live Results Link: https://tinyurl.com/lkr3gzm
-- Prize Winners
SPARQL
PREFIX wd:
PREFIX wdt:
PREFIX wikibase:
PREFIX p:
PREFIX ps:
PREFIX pq:
PREFIX psv:
PREFIX rdfs:
PREFIX bd:
SELECT ?person ?dbpediaID ?place ?dbpediaPlaceID ?longitude ?latitude?name ?coord ?image ?almamater ?article
WHERE
{ SERVICE {
SELECT ?name ?coord ?image ?almamater ?article ?place ?person
WHERE {
?person wdt:P166 wd:Q47170 ;
wdt:P69 ?place .
?place wdt:P625 ?coord
OPTIONAL{ ?person wdt:P18 ?image }
OPTIONAL{ ?article schema:about ?person ; schema:isPartOf }
?person rdfs:label ?name filter (lang(?name) = "en")
?place rdfs:label ?almamater filter (lang(?almamater) = "en")
}
}
SERVICE {
SELECT ?person ?place ?dbpediaID ?dbpediaPlaceID ?longitude ?latitude
FROM
WHERE {
?dbpediaID owl:sameAs ?person .
?dbpediaPlaceID owl:sameAs ?place ;
geo:lat ?latitude ;
geo:long ?longitude .
}
}
}
-- Live Results Link: https://tinyurl.com/lodjceo