使用dbpedia-owl:wikiPageRedirect值检索资源的dbpedia-owl:type值? [英] Retrieving dbpedia-owl:type value of resource with dbpedia-owl:wikiPageRedirect value?
问题描述
访问 http://dbpedia.org/resource/Cupertino 显示有关Cupertino的DBpedia RDF信息.如您所见,它具有以下特性和价值:
Visitng http://dbpedia.org/resource/Cupertino shows the DBpedia RDF information about Cupertino. As you can see, it has, among others, the property and value:
dbpedia-owl:type dbpedia:City
但是,在DBpedia端点上的此查询不返回任何结果:
However, this query on the DBpedia endpoint returns no results:
SELECT ?type WHERE {
dbpedia:Cupertino dbpedia-owl:type ?type
}
Why can't I retrieve the value of the dbpedia-owl:type
property?
推荐答案
您面前有一个交互式Web服务,您可以做的最有用的事情之一就是 generalize 查询到一个应该返回您正在寻找的结果的超集的表,作为一种健全性检查.在这种情况下,查看请求 all 属性和值dbpedia:Cupertino
会发生什么会很有用.
You've got an interactive webservice in front of you, and one of the most useful things that you can do is generalize your query into one that should return a superset of the results you're looking for, as a sort of sanity check. In this case, it's useful to see what happens if you ask for all properties and values of dbpedia:Cupertino
.
select ?p ?o where {
dbpedia:Cupertino ?p ?o
}
在这种情况下, In this case, that 要在查询中使用 To use dbpedia-owl:wikiPageRedirects
非常重要.当您键入dbpedia:Cupertino
或完整的URI时, http://dbpedia.org/resource/Cupertino ,然后在网络浏览器中仔细查看最终结果.您最终到达 http://dbpedia.org/page/Cupertino,_California ,这意味着您实际询问的资源是 http://dbpedia.org/resource/Cupertino,_California(在浏览器中检索它们时,会将您从/resource/
重定向到/page/
,但是命名约定仍然相同.dbpedia-owl:wikiPageRedirects
is very important. When you type in dbpedia:Cupertino
or the full URI, http://dbpedia.org/resource/Cupertino, into a web browser, look carefully at where you end up. You end up at http://dbpedia.org/page/Cupertino,_California, which means that the resource you're actually asking about is http://dbpedia.org/resource/Cupertino,_California (when you retrieve them in a browser, you're redirected from /resource/
to /page/
, but the naming convention is still the same. dbpedia:Cupertino
,您需要添加重定向信息.因此,您可以使用以下查询来获取所需的结果:dbpedia:Cupertino
in a query, you'd need to add the redirect information. Thus, you could use the following query to get the results that you're looking for:select ?type where {
dbpedia:Cupertino dbpedia-owl:wikiPageRedirects*/dbpedia-owl:type ?type
}