Giter VIP home page Giter VIP logo

Comments (18)

mwkuster avatar mwkuster commented on July 30, 2024

Version of the libraries used:
sparql (1.0.7)
sparql-client (1.0.1)
(the latest one available via Ruby-Gem).

from sparql.

gkellogg avatar gkellogg commented on July 30, 2024

Congratulations for finding a corner case not present in the test cases. Complex as it is, everything in here should be supported. I'll try to simplify this to get at the root problem.

from sparql.

mwkuster avatar mwkuster commented on July 30, 2024

Promise, didn't do it on purpose :-)

Please le me know if I can be of any assistance

from sparql.

gkellogg avatar gkellogg commented on July 30, 2024

It ended up being fairly straightforward (presuming that the query actually does what you want). CONCAT was defined to take just two arguments, not a variable number of arguments. Simple update to use Enumerable#inject to get results.

from sparql.

mwkuster avatar mwkuster commented on July 30, 2024

Thanks a lot! Technically it works now (I've just locally replaced in the Gem concat.rb) with the new version

However, the end result is very different from the one using ARQ (Jena version 2.10.0) on the same query, and I would like to think that ARQ's results are the good ones:

Source: https://github.com/mwkuster/eli-budabe/blob/master/sparql/source.ttl

ARQ's results: https://github.com/mwkuster/eli-budabe/blob/master/sparql/sparql_arq.ttl

The library's results: https://github.com/mwkuster/eli-budabe/blob/master/sparql/sparql_ruby.ttl

Query is unchanged: https://github.com/mwkuster/eli-budabe/blob/master/sparql/eli_md.rq

from sparql.

gkellogg avatar gkellogg commented on July 30, 2024

I new it wouldn't be that easy :(. I'll need to be sure I'm generating the same algebra; if so, I should also get the same results.

from sparql.

mwkuster avatar mwkuster commented on July 30, 2024

Just to alert you that I've committed a slightly modified version of the original query (strictly no impact on the results with ARQ and the library, though)

from sparql.

mwkuster avatar mwkuster commented on July 30, 2024

Sorry to slightly highjack this ticket for a related question, but is there a defined interface to register specific new custom extension functions? If so, must they also be derived from Operator with the Evaluatable mixin?

from sparql.

gkellogg avatar gkellogg commented on July 30, 2024

There isn't yet a way to define custom functions; if there were, it would be by extending evaluatable, as with others such functions. It would also need a way to register the classes, so they could be dispatched. I'd certainly consider submissions to handle this.

The current issue seems to relate to a difference in generating the algebra for the query; I'm tied up at the moment, but will get to it. It's also possible to directly execute an SSE query, which could be an alternative for you in the mean time.

from sparql.

mwkuster avatar mwkuster commented on July 30, 2024

OK, can have a go at the custom functions, probably not before the weekend though

from sparql.

gkellogg avatar gkellogg commented on July 30, 2024

@mwkuster, I found an error in how the algebra was being generated, which could have accounted for the differences in output you were seeing. Could you check your results again with the top of the master branch?

from sparql.

mwkuster avatar mwkuster commented on July 30, 2024

thanks, but unfortunately no luck yet (Gem updated based on git clone https://github.com/ruby-rdf/sparql.git, then gem1.9 build sparql.gemspec ):

irb(main):003:0> g = SPARQL.execute(e.legal_resource_query, e.repo)
NoMethodError: undefined method join' for nil:NilClass from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/iri.rb:34:inapply'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/evaluatable.rb:16:in evaluate' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:40:inblock (2 levels) in execute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:38:in each' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:38:inblock in execute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:36:in each' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:36:inexecute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/join.rb:39:in execute' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/left_join.rb:38:inexecute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:35:in execute' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/construct.rb:41:inexecute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/prefix.rb:30:in execute' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql.rb:85:inexecute'
from (irb):3
from /opt/local/bin/irb1.9:12:in `

'
irb(main):004:0> e.legal_resource_query
=> "PREFIX cdm: http://publications.europa.eu/ontology/cdm#\nPREFIX eli: http://eurlex.europa.eu/eli#\nPREFIX xsd: http://www.w3.org/2001/XMLSchema#\nPREFIX owl: http://www.w3.org/2002/07/owl#\n\nCONSTRUCT {\n ?eli eli:id_document ?eli_str ;\n eli:type_document http://publications.europa.eu/resource/authority/resource-type/dir ;\n eli:agent_document ?agent_document ;\n eli:id_local ?celex ;\n eli:is_about ?eurovoc ;\n eli:date_document ?date_document ;\n eli:date_entry-in-force ?date_entry_in_force ;\n eli:date_no-longer-in-force ?date_no_longer_in_force ;\n eli:cites ?cites ;\n eli:transposes ?transposes ;\n eli:based_on ?based_on ;\n eli:basis_for ?basis_for ;\n eli:changes ?changes ;\n eli:changed_by ?changed_by .\n ?expr_eli eli:expression_title ?title ;\n eli:language_expression ?lang ;\n eli:belongs_to ?eli .\n ?manif_eli eli:manifests ?expr_eli ;\n eli:link_manifestation ?item ;\n eli:publisher "Publications Office"@en .\n} WHERE {\n ?subj cdm:work_created_by_agent ?agent_document ;\n cdm:resource_legal_id_celex ?celex ;\n cdm:work_date_document ?date_document .\n OPTIONAL { ?subj cdm:work_is_about_concept_eurovoc ?eurovoc }\n OPTIONAL {?subj cdm:resource_legal_date_entry-into-force ?date_entry_in_force }\n OPTIONAL {?subj cdm:resource_legal_date_end-of-validity ?date_no_longer_in_force }\n OPTIONAL { ?subj cdm:work_cites_work ?cites }\n OPTIONAL { ?subj cdm:resource_legal_based_on_resource_legal ?based_on }\n OPTIONAL { ?subj cdm:resource_legal_implemented_by_resource_legal ?transposes }\n OPTIONAL { ?subj cdm:directive_implemented_by_measure_national_implementing ?transposes }\n OPTIONAL { ?subj cdm:resource_legal_basis_for_resource_legal ?basis_for }\n OPTIONAL { ?subj cdm:resource_legal_amends_resource_legal ?changes } #and many more variants\n OPTIONAL { ?subj cdm:resource_legal_amended_by_resource_legal ?changed_by }\n BIND (http://eli.budabe.eu/eli/dir/2010/24/oj AS ?eli)\n BIND (str(?eli) AS ?eli_str)\n\n ?expr cdm:expression_title ?title .\n ?expr cdm:expression_uses_language ?lang .\n BIND ( IRI(lcase(replace(str(?expr), "^.\.([A-Z]{3})$", concat(?eli_str, "/", "$1")))) AS ?expr_eli)\n\n ?manif cdm:manifestation_manifests_expression ?expr .\n OPTIONAL { \n ?manif_cellar_id owl:sameAs ?manif .\n ?item cdm:item_belongs_to_manifestation ?manif_cellar_id . \n } #Print manifestations have no link to a file\n BIND ( IRI(lcase(replace(str(?manif), "^.\.([A-Z]{3})\.([a-z0-9]+)$", concat(?eli_str, "/", "$1", "/", "$2")))) AS ?manif_eli)\n}"
irb(main):005:0>

from sparql.

gkellogg avatar gkellogg commented on July 30, 2024

That problem was due to running the query without a base URI; I corrected this in fc13d9e. Can you verify that you have that version, with the updated iri.rb?

from sparql.

gkellogg avatar gkellogg commented on July 30, 2024

I verified running your example with https://github.com/ruby-rdf/sparql/blob/master/examples/issue9.rb, but didn't exhaustively check the actual results; the algebra which is created now should be identical to that from ARQ.

from sparql.

mwkuster avatar mwkuster commented on July 30, 2024

Did another git pull and rebuilt the gem. However, get now another error (same query as before):

e.legal_resource_query: as before
e.repo: Repository based on https://github.com/mwkuster/eli-budabe/blob/master/sparql/source.ttl

irb(main):003:0> g = SPARQL.execute(e.legal_resource_query, e.repo)
NoMethodError: undefined method execute' for #<Array:0x007fb2ce6df758> from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:35:inexecute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/project.rb:30:in execute' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/distinct.rb:32:inexecute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/prefix.rb:30:in execute' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql.rb:85:inexecute'
from /Users/marcwilhelmkuster/sandbox/OP/eli-budabe/eli.rb:60:in eli' from /Users/marcwilhelmkuster/sandbox/OP/eli-budabe/eli.rb:76:inlegal_resource_query'
from (irb):3
from /opt/local/bin/irb1.9:12:in `

'
irb(main):004:0>

from sparql.

mwkuster avatar mwkuster commented on July 30, 2024

Sorry, wrong alarm. This is an entirely unrelated issue. Having tested the result with the new version I can confirm that everything looks great now. Thanks a lot!

from sparql.

mwkuster avatar mwkuster commented on July 30, 2024

However, the library does fail on a different query with said error message. Since it seems a different problem, I've opened a new ticket for it

from sparql.

gkellogg avatar gkellogg commented on July 30, 2024

Cool.

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.