Skip to content

Instantly share code, notes, and snippets.

@danielhmills
Last active February 17, 2021 19:37
Show Gist options
  • Save danielhmills/9210f687aa862cd54dd2d6b2f4fb585c to your computer and use it in GitHub Desktop.
Save danielhmills/9210f687aa862cd54dd2d6b2f4fb585c to your computer and use it in GitHub Desktop.
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
prefix ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT DISTINCT
?actor
?name
?same
dbo:spouse as ?spouseProp
?spouse
?spouseName
wdt:P451 as ?partnerProp
?unmarriedPartner
?unmarriedPartnerName
?startDate
?endDate wdt:P166 as ?awardProp
?award
?awardName
substr(str(?year),0,4) as ?year
?movie
?movieName
WHERE
{
#Data From DBpedia
SERVICE <http://dbpedia.org/sparql/>
{
?actor rdfs:label ?name; owl:sameAs ?same; dbo:spouse ?spouse.
?spouse rdfs:label ?spouseName.
FILTER(?name = 'Robert Downey Jr.'@en && CONTAINS(str(?same),str(wd:)) && lang(?spouseName) = 'en').
}
#Data From Wikidata
SERVICE <https://query.wikidata.org/sparql>
{
?same wdt:P451 ?unmarriedPartner;
wdt:P166 ?award.
OPTIONAL{
<http://www.wikidata.org/entity/Q165219> p:P166 [
ps:P166 ?event; pq:P585 ?year; pq:P1686 ?movie].
}.
?movie rdfs:label ?movieName.
FILTER(lang(?movieName) = 'en').
OPTIONAL{
?same p:P451 [ps:P451 ?unmarriedPartner;
pq:P580 ?startDate;
pq:P582 ?endDate
].
}
?unmarriedPartner rdfs:label ?unmarriedPartnerName.
?award rdfs:label ?awardName.
FILTER(lang(?unmarriedPartnerName) = 'en' && lang(?awardName) = 'en' )
}
}
LIMIT 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment