Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting started with DBpedia

Tags:

sparql

dbpedia

I want to get started using DBpedia. At the moment all I know is that DBpedia is a structured form of Wikipedia data and it can be queried using SPARQL. To me the basic idea of DBpedia (giving structure to wikipedia data) seems truly amazing, so please go easy if my question is basic.

My goal

Get simple data extracts from DBpedia. For example the countries of the world and their capitals and populations. Or get 100 random famous people, their dates and places of birth and a short description. Eventually I want to query the metadata to find what types of 'entity' are in DBpedia (eg mountains? Rivers? Cities?) and their 'properties'. But that is a separate question and I can experiment once I get the basics working.

What I found so far

In Google I found http://wiki.dbpedia.org/develop/getting-started but I think it's about installing all of DBpedia, and I only want to query it.

Also I found https://mickael.kerjean.me/2016/05/20/walkthrough-dbpedia-and-triplestore/ but it assumes you already have SPARQL or SNORQL set up, and I can't see how to do this.

Aso I found https://docs.data.world/tutorials/sparql/Your_First_Sparql_Query.html which is a guide to SPARQL but again it assumes you are using their own DataWorld environment.

On Stackoverflow I found List countries from DBpedia and List countries from DBpedia but again they assume you have set up the SPARQL environment.

Question(s)

  1. What software do I use to write simple queries on DBpedia data - do I need SPARQL or SNORQL? Do I install them locally or can I use web-based tools? I use Windows 10 and I'm happy with SQL queries.
  2. Once I have the software set up, what is the simplest query to get the list of countries of the world and capitals and populations?
  3. Also how can I write a basic query to return (say) 100 random people and their basic details?
like image 969
Ubercoder Avatar asked Feb 14 '18 15:02

Ubercoder


People also ask

How do I access DBpedia?

DBpedia Live SPARQL Endpoint: The DBpedia-Live SPARQL Endpoint can be accessed at http://live.dbpedia.org/sparql.

What is DBpedia SPARQL?

SPARQL (pronounced "sparkle" /ˈspɑːkəl/, a recursive acronym for SPARQL Protocol and RDF Query Language) is an RDF query language—that is, a semantic query language for databases—able to retrieve and manipulate data stored in Resource Description Framework (RDF) format.


2 Answers

The answer regarding your first question,actually SPARQL is a query language not a software and you can write your queries here https://dbpedia.org/sparql.

In-order to obtain countries ,their capital and respective population :

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT  min(?country_name) as ?Country_name min(?capital_name) as ?Capital_name min(?population) as ?Population
WHERE {
?country a dbo:Country.
?country rdfs:label ?country_name.
?country dbo:capital ?capital.
?capital  rdfs:label ?capital_name.
?country ?p ?population .
FILTER(?p = dbo:populationTotal || ?p = dbp:populationCensus). 
FILTER NOT EXISTS { ?country dbo:dissolutionYear ?year }
FILTER langMatches( lang(?country_name), "en"  ).
FILTER langMatches( lang(?capital_name), "en"  ).}
GROUP BY ?country_name

For your third question, this is an example solution :

SELECT  distinct ?link ?person_full_name ?birth_year   WHERE { 
     ?link a foaf:Person. 
     ?link ?p ?person_full_name. 
     FILTER(?p IN(dbo:birthName,dbp:birthName,dbp:fullname,dbp:name)). 
     ?link rdfs:label ?person_name .    
     ?person_name bif:contains "abdul" . 
     OPTIONAL { ?link dbo:birthYear ?birth_year .  }
     FILTER(langMatches(lang(?person_full_name), "en"))
     }
     LIMIT 100
like image 52
Coder Avatar answered Sep 29 '22 10:09

Coder


Check out About DBpedia and Using DBpedia.

Also

  • SPARQL interface -- the SPARQL environment is already there
  • Faceted Browser -- another way to explore the data
  • Graphical SPARQL Query Builder, iSPARQL
  • SNORQL interface
like image 38
TallTed Avatar answered Sep 29 '22 10:09

TallTed