kabal
kabal

Reputation: 49

Having trouble querying dbpedia

I am building a database in SQL Server involving UFC fighters and matches. I have been entering data manually and recently discovered I might be able to use DBpedia to get mass data results. I've tried looking for many DBpedia tutorials, and I'm having a lot of trouble wrapping my head around the SPARQL language and attempting to query the DBpedia.

Basically, I want to pull data from the Wikipedia infobox on a fighter profile, to get basic information such as name, dob, height, birth place, etc. This data would then be entered into SQL Server.

So can someone show me how I would get that information from a DBpedia query using something like http://dbpedia.org/sparql for this page/fighter for example --

And if that is possible, is it also possible to gather this information for every fighter in a fighter category such as Category:American_mixed_martial_artists?

Any help or exact queries would be very much appreciated. I've been fine learning SQL, so far but this SPARQL language and things like RDF I'm finding difficult

Edit: here is my attempt to just retrieve name

SELECT ?name
  WHERE
    {
      ?person dc:subject dbp:cat:American_mixed_martial_artists.
      ?person foaf:givenName ?name
    }

EDIT: Comment into question --

Why doesn't this query return the names of all the subjects in American mixed martial artists?

SELECT * 
WHERE 
  { ?e  <dbpedia.org/ontology/subject>    <dbpedia.org/resource/American_mixed_martial_artists>  . 
    ?e  <dbpedia.org/ontology/givenName>  ?name 
  }

Upvotes: 0

Views: 208

Answers (1)

jimkont
jimkont

Reputation: 923

There are a lot of typos in the query. Here's a version that works (note the dct:subject not dc:)

SELECT ?name WHERE {
  ?person dct:subject <http://dbpedia.org/resource/Category:American_mixed_martial_artists>.
  ?person foaf:givenName ?name
}

For the second query, the prefixes (dct, foaf) are expanded incorrectly and the category page is missing the http:// and the Category:

Upvotes: 1

Related Questions