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)
当我使用DISTINCT解决方案修饰符时,我得到大约220万个结果.
PREFIX prop:<http://dbpedia.org/property/>
select count(DISTINCT ?x) where {
?x prop:name ?y
}
Run Code Online (Sandbox Code Playgroud)
我有两个问题:
像这样的查询可用于检索(最多10个)空白节点:
select ?bnode where {
?bnode ?p ?o
filter(isBlank(?bnode))
}
limit 10
Run Code Online (Sandbox Code Playgroud)
但是,我没有得到任何结果.它看起来不像DBpedia数据中有空白节点(无论如何).
您的查询返回不同数量的结果的原因是它?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,并且我的样本数据中只有一个.这是一种最终可以得到不同数量结果的方法,它不需要任何空白节点.
| 归档时间: |
|
| 查看次数: |
524 次 |
| 最近记录: |