- From: Aymeric Brisse <aymeric.brisse@gmail.com>
- Date: Thu, 20 Jan 2022 08:23:51 +0100
- To: Gregg Kellogg <gregg@greggkellogg.net>
- Cc: Daniel Hernandez <daniel@degu.cl>, W3C Ruby RDF mailing list <public-rdf-ruby@w3.org>, Andy Seaborne <andy@seaborne.org>
- Message-ID: <CANURzhjePLU2CM0Xo51+mHdQ3RkNof3bu1R085WADFkHP4wKhA@mail.gmail.com>
Thank you Gregg that looks really awesome! On Wed, Jan 19, 2022, 22:50 Gregg Kellogg <gregg@greggkellogg.net> wrote: > For those following the SPARQL re-serialization issue: While there was > initial support un release 3.2.0 of the sparql gem, this was limited to > fairly trivieal use cases. In 3.2.1 [1][2] there’s fairly comprehensive > support for all but the most complicated SPARQL expressions with most > test-suite inputs now re-serializable. This includes SPARQL-star tests. > > Gregg Kellogg > gregg@greggkellogg.net > > [1] https://github.com/ruby-rdf/sparql/releases/tag/3.2.1 > [2] https://rubygems.org/gems/sparql > > On Dec 27, 2021, at 1:33 PM, Gregg Kellogg <gregg@greggkellogg.net> wrote: > > Support for #to_sparql on Operator, and other classes, is no implemented > on the develop branch, and will be released shortly in a 3.1.0 release. > > It should work for simple queries, but will likely run into issues for > things that get too complicated. It does include re-serializing any prefix > or base IRI declarations and using to shorten embedded IRIs, as well as for > updates as well as queries. > > From Daniel’s original example: > > query = SPARQL.parse 'SELECT ?s WHERE { ?s ?p ?o }’ > query.to_sparql #=> "SELECT ?s\nWHERE {\n?s ?p ?o .\n}\n” > > There’s really no attempt at trying to make whitespace pretty, I’m afraid. > > See https://github.com/ruby-rdf/sparql/issues/38 > > Thanks to Aymeric and Andy for suggestions, although the approach taken is > somewhat different. > > Gregg Kellogg > gregg@greggkellogg.net > > On Dec 2, 2021, at 3:05 AM, Daniel Hernandez <daniel@degu.cl> wrote: > > > Thank you for your answer. I think now I understand better the role > that play SPARQL::Grammar, SPARQL::Algebra, and SPARQL::Client (please > fix me if I am wrong). The first two allow for creating instances of an > algebraic expression from a string (using either the SPARQL or the SSE > grammars), and can be translated to SSE. The last provides a DSL to > define queries, and does not care about the SPARQL algebra. > > Gregg, I am going to implement the hypothetical method inside my app, > for some few cases, and then I am going to share the code to see if this > is useful for the general implementation. > > Daniel Hernández > > Gregg Kellogg <gregg@greggkellogg.net> writes: > > The approach Jena takes probably makes it better to have such a mechanism > be part of the core sparql gem, not restricted to sparq-client. I created > an issue for it in the sparql repo [1]. > > A hypothetical SPARQL::Algebra::Operator#to_sparql method might method > that could be used to do this. > > Gregg Kellogg > gregg@greggkellogg.net > > [1] https://github.com/ruby-rdf/sparql/issues/38 < > https://github.com/ruby-rdf/sparql/issues/38> > > On Dec 1, 2021, at 1:45 PM, Gregg Kellogg <gregg@greggkellogg.com> wrote: > > Thanks Andy, that’s what I was looking for. Could be ported to Ruby > reasonably. > > Gregg Kellogg > > SPARQL::Algebra::Operator>> Sent from my iPhone > > > On Dec 1, 2021, at 1:13 PM, Andy Seaborne <andy@seaborne.org> wrote: > > > > On 01/12/2021 20:30, Gregg Kellogg wrote: > (Sorry, previous reply was inadvertently not reply all). > I recall some discussion about this several years ago, and it may be > possible, at least in limited cases. I’m also not aware of any other > platforms which use SPARQL S-Expressions which do any de-compilation. > > > Jena tries to - it's quite pragmatic: > > > https://github.com/apache/jena/blob/main/jena-arq/src/main/java/org/apache/jena/sparql/algebra/OpAsQuery.java > > Andy > > I had thought that this would be good for the sparql-client gem, which > could take an SSE input and turn it into SPARQL Grammar, and for trivial > use cases it shouldn’t be too difficult to do, but I never pursued the > issue. I’d be happy for someone to look into this further and maybe create > a PR, even if it is only a partial solution. To not get lost, it might be > good to create an issue in > https://github.com/ruby-rdf/sparql-client/issues < > https://github.com/ruby-rdf/sparql-client/issues> so that we don’t loose > discussions again. > Typically, the SXP is intended for optimization and execution, not to > round trip back to the sparql grammar. There may be some other work on > this, but I’m not aware of any. There’s quire a bit of activity in > http://rdf.js.org/query-spec/ <http://rdf.js.org/query-spec/>c < > https://github.com/rdfjs/query-spec> for that JavaScript community, and > there may be some work there that could be leveraged. > In general, I would welcome more collaboration on the Ruby RDF/SPARQL > gems, which have been fairly quiet for a while, other than for basic > maintenance. I am planning a 3.2 release, but that will mostly be to > maintain dependencies and minimum Ruby versions. > Gregg Kellogg > gregg@greggkellogg.net <mailto:gregg@greggkellogg.net > <gregg@greggkellogg.net>> > > On Dec 1, 2021, at 6:35 AM, Daniel Hernandez <daniel@degu.cl < > mailto:daniel@degu.cl <daniel@degu.cl>>> wrote: > > > > In the previous example I made a mistake it is `parse` instead of `for` > (the question is the same). > > Daniel Hernandez <daniel@degu.cl <mailto:daniel@degu.cl <daniel@degu.cl>>> > writes: > > Hi all, > > I am trying to get the SPARQL query of a sse expression. > For instance, if I have > > exp = SPARQL::Algebra::Expression.for "(project (?x) (bgp (triple ?s ?p > ?x)))" > > then I want the string "SELECT ?x WHERE {?s ?p ?x}". > > Thanks, > Daniel > > > > > > >
Received on Thursday, 20 January 2022 07:24:15 UTC