简体   繁体   English

SPARQL查询以获取dbpedia类别的skos:broader属性

[英]SPARQL query to get skos:broader property of a dbpedia category

I am using the endpoint http://dbpedia.org/sparql to query dbpedia for "skos:broader" property given a category. 我正在使用端点http://dbpedia.org/sparql来查询dbpedia以获取给定类别的“ skos:broader”属性。 I've taken the categories from http://dbpedia.org/page/Andreessen_Horowitz to do the queries. 我从http://dbpedia.org/page/Andreessen_Horowitz中获取了类别进行查询。 I'm not sure what I did wrong in the following queries: 我不确定在以下查询中我做错了什么:

a. 一种。 I got syntax error with this one. 我对此有语法错误。 How do I escape ","? 我如何逃脱“,”?

prefix category: <http://dbpedia.org/resource/Category:>
select ?value where { 
  category:Companies_based_in_Menlo_Park,_California skos:broader ?value 
}

b. I got empty result with this one. 我得到了一个空结果。 But if I replaced the URI with "category:American_venture_capital_firms" then I got result back (with the proper prefix declaration). 但是,如果我用“ category:American_venture_capital_firms”替换了URI,那么我会得到结果(带有正确的前缀声明)。

select ?value where { 
  <http://dbpedia.org/page/Category:American_venture_capital_firms> skos:broader ?value 
}

Regarding point a, you can escape characters in a SPARQL 1.1 prefixed name by adding a backslash in front: 关于点a,可以通过在前面加上反斜杠来对SPARQL 1.1前缀名称中的字符进行转义:

category:Companies_based_in_Menlo_Park\,_California

Unfortunately, however, that does not work on the DBPedia endpoint, because its SPARQL engine is not fully up to date with the SPARQL 1.1 standard. 但是,不幸的是,这在DBPedia端点上不起作用,因为其SPARQL引擎尚未完全符合SPARQL 1.1标准。 A workaround is to use the full IRI instead of the prefixed name, by 'expanding' the prefix: 一种解决方法是通过“扩展”前缀来使用完整的IRI而不是前缀名称:

select ?value where { 
  <http://dbpedia.org/resource/Category:Companies_based_in_Menlo_Park,_California> skos:broader ?value 
}

Regarding point b: that query is not giving a result because you are using the wrong URI. 关于b点:该查询未给出结果,因为您使用的是错误的URI。 You have '...dbpedia.org/ page /Category:...' in your query, it should be '...dbpedia.org/ resource /Category:...'. 您的查询中有'... dbpedia.org/ 页面 / Category:...',它应该是'... dbpedia.org/ 资源 / Category:...'。

DBPedia URIs with /page/ in them are HTML info pages about a resource, whereas the URIs with /resource/ in them are the actual identifiers of the resource itself. 其中带有/ page /的DBPedia URI是有关资源的HTML信息页,而其中带有/ resource /的URI是资源本身的实际标识符。 The latter is what you should always be querying with SPARQL. 后者是您应该始终使用SPARQL查询的内容。

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

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