Big Data/Analytics Zone is brought to you in partnership with:

Enterprise Architect in HCL Technologies a $7Billion IT services organization. My role is to work as a Technology Partner for large enterprise customers providing them low cost opensource solutions around Java, Spring and vFabric stack. I am also working on various projects involving, Cloud base solution, Mobile application and Business Analytics around Spring and vFabric space. Over 23 yrs, I have build repository of technologies and tools I liked and used extensively in my day to day work. In this blog, I am putting all these best practices and tools so that it will help the people who visit my website. Krishna is a DZone MVB and is not an employee of DZone and has posted 64 posts at DZone. You can read more from them at their website. View Full User Profile

SPARQL and dbpedia: Getting Structured Data from Wikipedia

01.17.2013
| 3772 views |
  • submit to reddit

I always wondered if you could extract structured data from Wikipedia. Then I stumbled upon DBPedia and SPARQLDBPedia stores Wikipedia data as a dataset, and it can be accessed using SPARQL. Let me demonstrate this with an example.

DBPedia has a SPARQL endpoint. And you can use SNORQL for exploring DBPedia. Let us execute the below SPARQL query in SNORQL and notice the resultset that is returned:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT ?film_title ?star_name
where {?film_title rdf:type <http://dbpedia.org/ontology/Film> .
?film_title  foaf:name ?film_name .
?film_title rdfs:comment ?film_abstract .
?film_title dbpedia-owl:starring ?star .
?star dbpprop:name ?star_name
}
LIMIT 5

I get the results as below:

SPARQL results from DBPedia

SPARQL results from DBPedia

As good place to learn SPARQL is http://answers.semanticweb.com/ 

Published at DZone with permission of Krishna Prasad, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)