Parsing DBPedia result

Hello,



I’ve just been thrown into a project that requires me to parse information
from DBPedia based upon certain keywords. The example in the demo is the
name of the city, which should return me the English description of that
city for the demo.

I’ve scrambled my own SPARQL query together for the endpoint at DBPedia. I’m
by no means experienced in semantics, as I just got plunged into this world..
My query looks like this:



dbpedia_url = "
http://dbpedia.org/sparql?default-graph-uri=http://dbpedia.org&query="

    query = "

      PREFIX dbo: <http://dbpedia.org/ontology/>

      PREFIX prop: <http://dbpedia.org/property/>

      SELECT ?abstract

      WHERE {

        ?city prop:name '#{city}'@en;

        a dbo:PopulatedPlace;

        dbo:abstract ?abstract

        FILTER langMatches( lang(?abstract), '#{language_code}')

      }"



Perhaps not the best approach, but it does what I expect it to do. When
running this through the browser, I seem to receive a collection of RDF data
(again, I’m not really sure what I’m talking about), and I just want to get
the value in Ruby as a string. Would RDF-for-Ruby be able to do this, and
would someone be so kind to point me in the right direction? I’m not looking
for a complete code example, just some advice on where to look for the
correct information.



To demo, enter the following query:



PREFIX dbo: <http://dbpedia.org/ontology/>

PREFIX prop: <http://dbpedia.org/property/>

SELECT ?abstract

WHERE { ?city prop:name 'Antwerpen'@en; a dbo:PopulatedPlace; dbo:abstract
?abstract

FILTER langMatches( lang(?abstract), 'en')}



At http://dbpedia.org/sparql

The info returned is what I want to work with.



*Arne De Herdt
**Software Engineer .NET/Ruby on Rails*



Email: arne.de.herdt@tenforce.com

Phone: +32 (0)16 31 48 64
Mobile: +32 (0)473 80 84 89
Web: http://www.tenforce.com



[image: Description:
http://www.tenforce.com/images/signature/mail-tenforce.jpg]

Received on Wednesday, 24 August 2011 12:33:51 UTC