Visitng http://dbpedia.org/resource/Cupertino显示了有关Cupertino的DBpedia RDF信息.如您所见,它具有财产和价值等: dbpedia-owl:type dbpedia:City 但是,DBpedia端点上的此查询不返回任何结果: SELECT ?type WHE
dbpedia-owl:type dbpedia:City
但是,DBpedia端点上的此查询不返回任何结果:
SELECT ?type WHERE { dbpedia:Cupertino dbpedia-owl:type ?type }
SPARQL results
为什么我无法检索dbpedia-owl:type属性的值?
你面前有一个互动的网络服务,你可以做的最有用的事情之一是将你的查询概括为一个应该返回你正在寻找的结果的超集的查询,作为一种健全性检查.在这种情况下,如果您要求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
在这种情况下,dbpedia-owl:wikiPageRedirects非常重要.当您在Web浏览器中键入dbpedia:Cupertino或完整URI http://dbpedia.org/resource/Cupertino时,请仔细查看最终结果.您最终在http://dbpedia.org/page/Cupertino,_California,这意味着您实际询问的资源是http://dbpedia.org/resource/Cupertino,_California(当您在浏览器中检索它们时,您将从/ resource /重定向到/ page /,但命名约定仍然相同.
要在查询中使用dbpedia:Cupertino,您需要添加重定向信息.因此,您可以使用以下查询来获取您正在查找的结果:
select ?type where { dbpedia:Cupertino dbpedia-owl:wikiPageRedirects*/dbpedia-owl:type ?type }
SPARQL results