How to get abstract and thumbnail of a Wikipedia article from article DBPedia?

半城伤御伤魂 提交于 2019-12-06 05:04:54

问题


I am new to SPARQL. With this query, I can get the birthName of Ernest Hemingway:

select distinct ?birthName
where {
  ?person a dbpedia-owl:Person .
  ?person dbpprop:birthName ?birthName .
  FILTER (regex(?birthName, "Ernest Miller Hemingway"))
} 
LIMIT 1

Is there a way I can get the wikipedia abstract/introduction and thumbnail of Ernest Hemingway with DBPedia?


回答1:


In general, the best way to start querying DBpedia if you already have an idea what you're looking for is to look at the page for the resource that you're interested in. In this case, you want

  • http://dbpedia.org/resource/Ernest_Hemingway, which redirects to
  • http://dbpedia.org/page/Ernest_Hemingway

On that page, you'll see that the property relating a resource to its abstract is dbpedia-owl:abstract, and the thumbnail or image is dbpedia-owl:thumbnail. Thus, you want a query like the following (which you can run on the DBpedia SPARQL endpoint). I've taken the liberty of restricting the results to just the English language abstract.

prefix dbpedia: <http://dbpedia.org/resource/>
prefix dbpedia-owl: <http://dbpedia.org/ontology/>

select ?abstract ?thumbnail where { 
  dbpedia:Ernest_Hemingway dbpedia-owl:abstract ?abstract ;
                           dbpedia-owl:thumbnail ?thumbnail .
  filter(langMatches(lang(?abstract),"en"))
}

SPARQL results



来源:https://stackoverflow.com/questions/19931728/how-to-get-abstract-and-thumbnail-of-a-wikipedia-article-from-article-dbpedia

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