Comments (18)
Version of the libraries used:
sparql (1.0.7)
sparql-client (1.0.1)
(the latest one available via Ruby-Gem).
from sparql.
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.
Promise, didn't do it on purpose :-)
Please le me know if I can be of any assistance
from sparql.
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.
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.
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.
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.
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.
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.
OK, can have a go at the custom functions, probably not before the weekend though
from sparql.
@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.
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:in
apply'
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:in
block (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:in
block 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:in
execute'
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:in
execute'
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:in
execute'
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:in
execute'
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.
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.
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.
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:in
execute'
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:in
execute'
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:in
execute'
from /Users/marcwilhelmkuster/sandbox/OP/eli-budabe/eli.rb:60:in eli' from /Users/marcwilhelmkuster/sandbox/OP/eli-budabe/eli.rb:76:in
legal_resource_query'
from (irb):3
from /opt/local/bin/irb1.9:12:in `
irb(main):004:0>
from sparql.
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.
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.
Cool.
from sparql.
Related Issues (20)
- Update query keywords are case-sensitive HOT 2
- Exception while parsing a query with path expression HOT 2
- Property path operator * unbinds variable HOT 5
- Query parser should report error when BIND is used with a variable that appears in the preceeding BGP
- SPARQL parsing drops the property paths when after a PROJECT HOT 1
- Random errors when parsing HOT 2
- Parser fails on empty `values` group
- Invalid SPARQL parsing
- Link to SPARQL S-Expressions (SSE) is down HOT 2
- Redefining Array#dup breaks lots of other things HOT 5
- sparql server fails HOT 2
- uninitialized constant Logger HOT 1
- Reverse SSE serializer HOT 5
- SELECT and FROM position
- BIND disappers when it used with VALUES HOT 5
- VAULES position looks wrong HOT 2
- PropertyPath's [ ] is missing. HOT 2
- SELECT * does not project all in-scope variables HOT 1
- Wrong permissions in gem files HOT 6
- Regex error with ruby 3.2 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sparql.