问题
Here's my query:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?resource ?parentOrSpouse
WHERE {
?resource a dbo:Royalty ;
rdfs:label ?label ;
dbo:parent ?parent ;
dbo:birthDate ?bd ;
dbo:birthPlace ?bp .
?bp dbo:isPartOf :England .
FILTER(?bd < '1900-01-01'^^xsd:dateTime) .
FILTER(?bd > '1800-01-01'^^xsd:dateTime) .
FILTER(LANGMATCHES(LANG(?label), 'en')) .
{ ?resource dbo:parent ?parentOrSpouse } UNION { ?resource dbo:spouse ?parentOrSpouse }
?parentOrSpouse dbo:birthPlace ?psbp .
?psbp dbo:isPartOf :England .
}
ORDER BY(?bd)
This searches for all royals born in England between 1800 and 1900 that have a spouse or parent that is born in England.
Result
In the result list I get
http://dbpedia.org/page/George_V with http://dbpedia.org/page/Mary_of_Teck listed as a spouse, but not Mary_of_Teck listed while George is clearly born in England.
Why is Mary disappearing? There are a lot of other people disappearing that should clearly be on the list when I look at the data.
回答1:
So the solution to Mary not showing up is to use dbo:parent|dbo:spouse/dbo:wikiPageRedirects?
, since George is refered by Mary via a redirect.
The other problem was dbo:birthPlace/dbo:location?/dbo:isPartOf dbr:England
throwing an error that is probably(?) related to a bug in the compiler. Using ?parentOrSpouse dbo:birthPlace|dbo:birthPlace/dbo:location/dbo:isPartOf :England .
instead seems to work fine.
Credit goes to @AKSW.
来源:https://stackoverflow.com/questions/53327523/results-filtered-out-even-though-the-data-is-there