-1

提前致谢。我有一个问题,合并一些工作会在我的三重存储中为单个主题生成两个 guid。我需要一种方法来隔离所有这些实例,以便我可以规范化这些 guid。我是 SPARQL 的新手。我试过用 COUNT 和 FILTER 返回这些,但到目前为止都失败了。这就是我们正在研究的内容。

<http://example.com/#bar> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://example.com/#choo> .
<http://example.com/#bar> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://example.com/#terms> .
<http://example.com/#bar> <http://www.w3.org/2008/05/skos-xl#prefLabel> 
<http://example.com/#bar/bar_en> .
<http://example.com/#bar> <http://www.foo.com/#guid> "17bda3bb-7db9-4afa- 
bb95-29da6464f137" .
<http://example.com/#bar> <http://www.foo.com/#guid> "1fa33bad-a98d-4a7e- 
8679-d8777e690c0c" .

对不起,包裹的文字使这更难阅读。但是,您可以在这里看到我有一个主题http://example.com/#bar,它有两个 guid。我在同一张图中有很多这样的案例,我需要一种方法来识别它们。再次感谢。

4

1 回答 1

2

正如@AKSW 的评论中提到的那样,您应该能够使用HAVING结合按主题分组来过滤聚合以实现此目的:

SELECT ?subject (COUNT(?guid) AS ?numGuids)
WHERE
{
  ?subject <http://www.foo.com/#guid> ?guid .
}
GROUP BY ?subject
HAVING (?numGuids > 1)
于 2018-06-19T12:54:25.900 回答