简体   繁体   中英

SPARQL and [property] of query

I'm trying to query data from a <http://dbpedia.org/ontology/Person> using SPARQL in DBpedia. However, the property I'm trying to match is listed as dbp:children of (example here: http://dbpedia.org/page/Angelina_Jolie ).

However, when making the query, dbp:childrenOf , dbo:children_of , and similar others don't work. How should I ask for that property?

Thanks!

Here my example query:

PREFIX   dbo:  <http://dbpedia.org/ontology/>
PREFIX  foaf:  <http://xmlns.com/foaf/0.1/>
PREFIX  rdfs:  <http://www.w3.org/2000/01/rdf-schema#>        
PREFIX  type:  <http://dbpedia.org/class/yago/>
PREFIX   dbp:  <http://dbpedia.org/property/> 

SELECT DISTINCT ?person ?birthDate ?birthPlace ?parents
WHERE {  
           ?person  a               dbo:Person .
         { ?person  rdfs:label      "Angelina Jolie"@en }
  UNION  { ?person  dbp:name        "Angelina Jolie"@en } .

           ?person  dbo:birthDate   ?birthDate.
           ?person  dbo:birthPlace  ?bp.
           ?bp      rdfs:label      ?birthPlace.
OPTIONAL { ?person  dbp:childrenOf  ?parents}
   FILTER (LANG(?birthPlace)='en')
}

The line I'm trying to fix is the OPTIONAL clause.

Unfortunately, I don't think any of Angelina's children have Wikipedia pages (therefore no DBpedia pages), so it's going to be difficult for you to resolve any answers with this particular example.

Here's a slightly different version of query for retrieving parents of a different person -

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>        
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX dbp: <http://dbpedia.org/property/> 

SELECT DISTINCT ?person ?birthDate ?birthPlace ?parents
WHERE {  
      ?person a dbo:Person .

      {?person rdfs:label "Ras Barker"@en}
      UNION 
      {?person dbp:name "Ras Barker"@en}
      UNION 
      {?person dbo:birthName "Ras Barker"@en}

      OPTIONAL { ?person dbo:birthDate ?birthDate. }
      OPTIONAL { ?person dbo:birthPlace ?bp . ?bp rdfs:label ?birthPlace. }
      #OPTIONAL { ?person dbo:parent ?parents }
      OPTIONAL { ?parents dbo:child ?person }
      FILTER (LANG(?birthPlace)='en')
}

I've opted to use the dbo predicate child instead of childrenOf (not sure this predicate is in use). And wrapped the birth-related stuff up into OPTIONAL clause, as you can't be 100% reliant on the instance data having these predicates in place.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM