gpt4 book ai didi

java - 如何排除具有特定 rdf :type from SPARQL results? 的资源

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:46:10 25 4
gpt4 key购买 nike

我在上面运行了这个查询 SPARQL.dbpedia.org/sparql:

select ?resource where {
?resource rdfs:label "Piemonte"@it
}

我得到这个结果:

http://it.dbpedia.org/resource/Categoria:Piemonte
http://it.dbpedia.org/resource/Piemonte

我只想拥有 http://it.dbpedia.org/resource/Piemonte因此。我正在尝试编写此查询 SPARQL 以删除 http://it.dbpedia.org/resource/Categoria:Piemonte从结果来看:

select ?resource where {
?resource rdfs:label "Piemonte"@it
FILTER (rdf:type != skos:Concept)
}

因为我注意到 http://it.dbpedia.org/resource/Categoria:Piemonte具有对象 skos:Concepthttp://it.dbpedia.org/resource/Piemonte没有,但我得到了相同的结果。为什么?我在这里做错了什么?

我也尝试添加 LIMIT 1,但结果是 http://it.dbpedia.org/resource/Categoria:Piemonte,因为结果不是保证顺序相同。

最佳答案

使用像 FILTER (rdf:type != skos:Concept) 这样的过滤器,您只是在询问两个常量是否不相等。当然,URI rdf:typeskos:Concept 是不同的。

您想要的是一种资源,它没有属性 rdf:type 的值 skos:Concept。您可以通过 ?resource rdf:type skos:Concept 表明它确实有那个。因此,您的查询只需要一个过滤器来确保数据中不存在该三元组。在意大利语 DBpedia 上,您可以提出以下问题并只得到一个结果。

select ?resource where {
?resource rdfs:label "Piemonte"@it
filter not exists { ?resource rdf:type skos:Concept }
}

SPARQL results

关于java - 如何排除具有特定 rdf :type from SPARQL results? 的资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24167256/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com