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

Re: Parsing DBPedia result

From: Ross Singer <rossfsinger@gmail.com>
Date: Wed, 24 Aug 2011 10:22:21 -0400
Message-ID: <CAF0_2KtFimG2izFd_dJR_QZ441q2k1sC0Y==D2N9wGVA_T_iqQ@mail.gmail.com>
To: Tom Morris <tom@tommorris.org>
Cc: Arne De Herdt <arne.de.herdt@tenforce.com>, public-rdf-ruby@w3.org
It's also worth looking at sparql-client
(http://sparql.rubyforge.org/client/) although it doesn't appear to
support more complicated queries, UNIONs, etc., but would definitely
handle your current queries.

The nice part of this is that it supplies a simple DSL for building
your queries and also parses the results into native ruby objects.

-Ross.

On Wed, Aug 24, 2011 at 8:52 AM, Tom Morris <tom@tommorris.org> wrote:
> [On Mon, Aug 22, 2011 at 14:37, Arne De Herdt
> <arne.de.herdt@tenforce.com> wrote:
>> 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:
>>
>>
>> The info returned is what I want to work with.
>>
>
> Hi Arne,
>
> You are doing a SELECT query which returns back XML in the SPARQL
> Query Results XML Format [1] rather than RDF. Unlike RDF, this can be
> easily parsed using standard XML tools. In Ruby, the best tool for
> this is Nokogiri [2], which basically gives you a DOM-style object
> graph for navigating the returned XML.
>
> Basically, the SPARQL XML results format is essentially a big table,
> and isn't RDF data: it's just a list of all the results, much as you
> might get from a SQL query.
>
> Just run the query as an HTTP call (using something like Curb or even
> open-uri), parse it into Nokogiri, then extract from the XML document
> the data you need.
>
> [1] http://www.w3.org/TR/rdf-sparql-XMLres/
> [2] http://nokogiri.org/
>
> --
> Tom Morris
> <http://tommorris.org/>
>
>
Received on Wednesday, 24 August 2011 14:22:48 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 24 August 2011 14:22:49 GMT