简体   繁体   English

使用SPARQL通过其字符串名称检索DBpedia资源

[英]Retrieving a DBpedia resource by its string name with SPARQL

I am trying to get the resource describing country Romania by the country name with this query: 我正在尝试使用此查询通过国家/地区名称获取描述国家/地区罗马尼亚的资源:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX : <http://dbpedia.org/resource/>

SELECT DISTINCT ?x WHERE {
     ?x foaf:name 'Romania'
}

SPARQL results SPARQL结果

However, it does not retrieve anything. 但是,它不会检索任何内容。 How can I get the resource http://dbpedia.org/resource/Romania ( :Romania ) by the string 'Romania' . 我怎样才能获得的资源http://dbpedia.org/resource/Romania:Romania的字符串) 'Romania' If I want to retrieve the name of the country by the country resource I use the following query which works fine: 如果我想通过国家/地区资源检索国家/地区的名称,我使用以下查询,该工作正常:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX : <http://dbpedia.org/resource/>

SELECT DISTINCT ?x WHERE {
     :Romania foaf:name ?x
}

SPARQL results SPARQL结果

This ought to do it: 这应该这样做:

SELECT ?c
WHERE {
  ?c a dbo:Country ;
     foaf:name "Romania"@en .
  FILTER NOT EXISTS { ?c dbo:dissolutionYear ?y }
}

SPARQL results SPARQL结果

The critical quirk here is that "Romania" with no language tag is different from "Romania"@en . 这里的关键怪癖是"Romania"没有语言标签是由不同的"Romania"@en And then you also have a bunch of historical states that were also called Romania, so we filter out any of those that have years of dissolution. 然后你还有一堆历史状态,也被称为罗马尼亚,所以我们过滤掉任何有多年解散的状态。 DBpedia's data-completeness for years of dissolution isn't terrific, but all the Romanian ones, at least, are marked. DBpedia在解散多年后的数据完整性并不是很好,但至少所有罗马尼亚人的数据都是标记的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM