[英]SPARQL and [property] of query
I'm trying to query data from a <http://dbpedia.org/ontology/Person>
using SPARQL in DBpedia. 我正在尝试在DBpedia中使用SPARQL从<http://dbpedia.org/ontology/Person>
查询数据。 However, the property I'm trying to match is listed as dbp:children of
(example here: http://dbpedia.org/page/Angelina_Jolie
). 但是,我要匹配的属性被列为dbp:children of
(示例在这里: http://dbpedia.org/page/Angelina_Jolie
: http://dbpedia.org/page/Angelina_Jolie
)。
However, when making the query, dbp:childrenOf
, dbo:children_of
, and similar others don't work. 但是,在进行查询时, dbp:childrenOf
, dbo:children_of
和其他类似的方法不起作用。 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. 我要修复的行是OPTIONAL
子句。
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. 不幸的是,我不认为安吉丽娜(Angelina)的任何孩子都拥有Wikipedia页面(因此没有DBpedia页面),因此您很难通过该特定示例来解决任何答案。
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). 我选择使用dbo
谓词child
而不是childrenOf
(不确定此谓词是否正在使用)。 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. 将与出生相关的内容包装到OPTIONAL
子句中,因为您不能100%依赖具有这些谓词的实例数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.