如何从SPARQL中的DBpedia中检索空白节点,并使用DISTINCT解释减少的结果

Ama*_*mar 2 rdf semantic-web sparql dbpedia blank-nodes

我想要使​​用SPARQL查询检索空白节点.我使用DBpedia作为我的数据集.例如,当我使用以下查询时,我得到了大约340万个结果.

PREFIX prop:<http://dbpedia.org/property/>
select count(?x) where {
?x prop:name ?y
}
Run Code Online (Sandbox Code Playgroud)

SPARQL结果

当我使用DISTINCT解决方案修饰符时,我得到大约220万个结果.

PREFIX prop:<http://dbpedia.org/property/>
select count(DISTINCT ?x) where {
?x prop:name ?y
}
Run Code Online (Sandbox Code Playgroud)

SPARQL结果

我有两个问题:

  1. 是否在第二个查询中删除了120万条记录重复或空白节点或其他内容?
  2. 如何从DBpedia中检索空白节点及其值?

Jos*_*lor 5

获取空白节点

像这样的查询可用于检索(最多10个)空白节点:

select ?bnode where {
  ?bnode ?p ?o
  filter(isBlank(?bnode))
}
limit 10 
Run Code Online (Sandbox Code Playgroud)

但是,我没有得到任何结果.它看起来不像DBpedia数据中有空白节点(无论如何).

使用DISTINCT并重复结果

您的查询返回不同数量的结果的原因是它?x有多个名称.像你的第一个查询:

select count(?x) where { ?x prop:name ?y }
Run Code Online (Sandbox Code Playgroud)

数据如:

<somePerson> prop:name "Jim" .
<somePerson> prop:name "James" .
Run Code Online (Sandbox Code Playgroud)

会产生2,因为有两种方法可以匹配?x prop:name ?y. ?x势必会<somePerson>在两人面前,但?y被绑定到不同的名称.在像你的第二个查询:

select count(DISTINCT ?x) where { ?x prop:name ?y }
Run Code Online (Sandbox Code Playgroud)

你明确只计算了不同的值?x,并且我的样本数据中只有一个.这是一种最终可以得到不同数量结果的方法,它不需要任何空白节点.