Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 839
TheFooProgrammer Avatar asked Nov 12 '13 14:11

TheFooProgrammer


1 Answers

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

like image 198
Joshua Taylor Avatar answered Oct 23 '22 20:10

Joshua Taylor