0
votes

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 
  }
1
Have you looked at the mediawiki API? mediawiki.org/wiki/API:Main_page or if you knew what you were looking for category wise you could use the Wikipedia export en.wikipedia.org/wiki/Special:Export. Either way you'll have to create some sort of C#/VB CLR proc or function to get that directly from SQL. - Brad D
Can you show a SPARQL query that you tried so far. What you want is not difficult, and the concept of SPARQL, i.e. matching triples/graphs is also not really difficult. So I'm wondering why any simple tutorial couldn't help you so far. - UninformedUser
SELECT * WHERE { ?e <dbpedia.org/ontology/subject> <dbpedia.org/resource/American_mixed_martial_artists>. ?e <dbpedia.org/ontology/givenName> ?name } @AKSW Why doesn't that query return the names of all the subjects in American mixed martial artists. Also sorry I'm not sure how to wrap it in code for readability in a comment response. - kabal

1 Answers

1
votes

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: