[英]How to append results from multiple SPARQL queries and write them into RDF
[英]How to exclude resources with a specific rdf:type from SPARQL results?
我有这个查询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:Concept
而http://it.dbpedia.org/resource/Piemonte没有,但我得到相同的结果。 为什么? 我在这做错了什么?
我也尝试添加LIMIT 1
,但结果是http://it.dbpedia.org/resource/Categoria:Piemonte
,因为结果不保证是相同的顺序。
使用像FILTER (rdf:type != skos:Concept)
这样的FILTER (rdf:type != skos:Concept)
器,你只是问两个常量是否不相等。 URIs rdf:type
和skos:Concept
当然是不同的。
你想要的是一个没有skos:Concept
值的资源skos: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 }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.