Giter VIP home page Giter VIP logo

Comments (3)

gkellogg avatar gkellogg commented on July 30, 2024

Generating the query form from the algebra is a bit experimental, and it looks like you've encountered a corner-case. There is a problem in the SSE (((?a2 "a3") (?a4 "a4")) should probably be ((?a3 "a3") (?a4 "a4"))), but I don't even get that far, with an argument error being generated along the way, so there is some mismatch in gem versions resulting in different behavior. Regardless, this shouldn't happen.

I can't promise when I'll be able to look at this in any more detail, as I'm pretty swamped with standards work, and this is challenging code to work with.

from sparql.

danielhz avatar danielhz commented on July 30, 2024

Yes, I intended to write (?e3 "a3"). The same issue occurs if join is replaced with leftjoin.

from sparql.

danielhz avatar danielhz commented on July 30, 2024

I tested the following code with JRuby using the Jena library.

require 'jruby/core_ext'
require 'maven_require'

maven_require 'org.apache.jena:jena-core'
maven_require 'org.apache.jena:jena-arq'
maven_require 'org.apache.logging.log4j:log4j-api'
maven_require 'org.apache.logging.log4j:log4j-core'
maven_require 'org.apache.logging.log4j:log4j-slf4j-impl'

java_import 'org.apache.jena.sys.JenaSystem'
java_import 'org.apache.jena.sparql.algebra.Algebra'
java_import 'org.apache.jena.sparql.algebra.OpAsQuery'

JenaSystem.init

exp = <<-EOS
(extend ((?a1 "a1") (?a2 "a2"))
	(union
	 (extend
	  ((?a2 "a3") (?a4 "a4"))
	  (join (extend
		 ((?a5 "a5") (?a6 "a6"))
		 (bgp (triple ?s1 ?p1 ?o1) (triple ?s2 ?p2 ?o2) (triple ?s3 ?p3 ?o3)))
		(extend
		 ((?a7 "a7") (?a8 "a8"))
		 (bgp (triple ?s4 ?p4 ?o4) (triple ?s5 ?p5 ?o5)))))
	 (extend ((?a9 "a9") (?a10 "a10")) (bgp (triple ?s6 ?p6 ?o6)))))
EOS

ops = Algebra.parse(exp)
puts OpAsQuery.as_query(ops).to_s

The output is the following:

SELECT  *
WHERE
  {   { { { ?s1  ?p1  ?o1 .
            ?s2  ?p2  ?o2 .
            ?s3  ?p3  ?o3
            BIND("a5" AS ?a5)
            BIND("a6" AS ?a6)
          }
          { ?s4  ?p4  ?o4 .
            ?s5  ?p5  ?o5
            BIND("a7" AS ?a7)
            BIND("a8" AS ?a8)
          }
        }
        BIND("a3" AS ?a2)
        BIND("a4" AS ?a4)
      }
    UNION
      { ?s6  ?p6  ?o6
        BIND("a9" AS ?a9)
        BIND("a10" AS ?a10)
      }
    BIND("a1" AS ?a1)
    BIND("a2" AS ?a2)
  }

from sparql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.