Retrieving dbpedia-owl:type value of resource with dbpedia-owl:wikiPageRedirect value?

匆匆过客 提交于 2020-01-09 05:37:44

问题


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

However, this query on the DBpedia endpoint returns no results:

SELECT ?type  WHERE {
  dbpedia:Cupertino  dbpedia-owl:type ?type
}

SPARQL results

Why can't I retrieve the value of the dbpedia-owl:type property?


回答1:


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 
}

SPARQL results

p                                               o
http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/2002/07/owl#Thing
http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://dbpedia.org/ontology/Place
http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://dbpedia.org/ontology/PopulatedPlace
http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://dbpedia.org/ontology/Settlement
http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://schema.org/Place
http://dbpedia.org/ontology/wikiPageID          337802
http://dbpedia.org/ontology/wikiPageRevisionID  16202923
http://www.w3.org/2000/01/rdf-schema#label      "Cupertino"@en
http://dbpedia.org/ontology/wikiPageRedirects   http://dbpedia.org/resource/Cupertino,_California
http://xmlns.com/foaf/0.1/isPrimaryTopicOf      http://en.wikipedia.org/wiki/Cupertino
http://www.w3.org/ns/prov#wasDerivedFrom        http://en.wikipedia.org/wiki/Cupertino?oldid=16202923

In this case, that 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.

To use 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
}

SPARQL results



来源:https://stackoverflow.com/questions/23871225/retrieving-dbpedia-owltype-value-of-resource-with-dbpedia-owlwikipageredirect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!