W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > August 2011

Parsing DBPedia result

From: Arne De Herdt <arne.de.herdt@tenforce.com>
Date: Mon, 22 Aug 2011 15:37:43 +0200
Message-ID: <e17612ddaaecb6f59d0a729f39a1198a@mail.gmail.com>
To: public-rdf-ruby@w3.org
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]



image003.jpg
(image/jpeg attachment: image003.jpg)

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

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 24 August 2011 12:33:53 GMT