Re: Different encoding for RDF-star queries as S-Expressions with Jena

> On Jan 19, 2022, at 11:43 PM, Daniel Hernandez <daniel@degu.cl> wrote:
> 
> Hi all,
> 
> The SPARQL parsers in Ruby RDF and Jena produce different S-Expressions
> for queries with RDF-star. For instance, consider the following query:
> 
> SELECT *
> WHERE { { ?s ?p ?o BIND (<< ?s ?p ?o >> AS ?t) } }
> 
> Ruby RDF generates:
> 
> (extend ((?t (triple ?s ?p ?o))) (bgp (triple ?s ?p ?o)))
> 
> Jena generates:
> 
> (extend ((?t << ?s ?p ?o >>)) (bgp (triple ?s ?p ?o))) 
> 
> In my opinion, it is better to have and standard representation for all tools that
> generate S-Expressions. The problem here is that the result of parsing a
> SPARQL query with Ruby RDF cannot be interpreted by Jena (and vice versa).

Of course, there is no real standard for expressing queries as s-expressions, but Ruby RDF generally follows Jena. (Creating a normative S-Expression representation would be interesting, though).

It seems that for encoding RDF-star, Andy and I chose different representations. Taking a simple query such as the following:

PREFIX : <http://bigdata.com>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX ex:  <http://example.org/>

SELECT ?age ?c WHERE {
   ?bob foaf:name "Bob" .
   <<?bob foaf:age ?age>> ex:certainty ?c .
}

Jena produces the following:

(prefix ((: <http://bigdata.com>)
         (ex: <http://example.org/>)
         (foaf: <http://xmlns.com/foaf/0.1/>))
  (project (?age ?c)
    (bgp
      (triple ?bob foaf:name "Bob")
      (triple << ?bob foaf:age ?age >> ex:certainty ?c)
    )))

While, Ruby RDF outputs:

(prefix ((: <http://bigdata.com>)
         (foaf: <http://xmlns.com/foaf/0.1/>)
         (ex: <http://example.org/>))
 (project (?age ?c)
  (bgp
   (triple ?bob foaf:name "Bob")
   (triple (triple ?bob foaf:age ?age) ex:certainty ?c))))

I’m not sure if this is intentional on Andy’s part, as  `triple << ?bob foaf:age ?age >> ex:certainty ?c)` doesn’t really look like an S-Expression to my eyes, and the “triple” expression has already been established, but using that embedded triple expression made the most sense to me. It does lead to some complications in re-serializing, as SPARQL-star does have a TRIPLE function, which gets the same representation in Ruby RDF, and distinguishing between their use took some doing, but internally, it’s never been an issue.

I wasn’t able to get qparse to parse either form of S-Expression, but that’s likely an operator error.

Gregg

> Daniel
> 

Received on Thursday, 20 January 2022 22:10:42 UTC