使用SPARQL通过字符串名称检索DBpedia资源 [英] Retrieving a DBpedia resource by its string name with SPARQL

查看:120
本文介绍了使用SPARQL通过字符串名称检索DBpedia资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过以下查询通过国名来描述描述罗马尼亚的资源:

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结果

但是,它不会检索任何内容。如何通过字符串获取资源 http://dbpedia.org/resource/罗马尼亚:罗马尼亚罗马尼亚
如果我想通过国家/地区资源检索国家/地区的名称,请使用以下查询,该查询很好用:

However, it does not retrieve anything. How can I get the resource http://dbpedia.org/resource/Romania (:Romania) by the string '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结果

推荐答案

这应该做到:

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

SPARQL结果

关键问题这是没有语言标签的罗马尼亚 罗马尼亚 @en 不同。然后,您还拥有一堆也被称为罗马尼亚的历史州,因此我们会过滤掉那些已经解散多年的州。 DBpedia多年来解散的数据完整性并不出色,但是至少所有罗马尼亚语都带有标记。

The critical quirk here is that "Romania" with no language tag is different from "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.

这篇关于使用SPARQL通过字符串名称检索DBpedia资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆