antoniogarrote / stardog-rb

Ruby bindings for Stardog HTTP API
Other
10 stars 3 forks source link

Reasoning issue #3

Open colorprint opened 10 years ago

colorprint commented 10 years ago

I have an ontology with SWRL rules. With the CLI stardog client the queries that depends on these rules works fine with the reasoning=SL: stardog query "onto1;reasoning=SL" "SELECT ?r where { PC:PersonalCollection_2 PC:hasResourceByLanguage ?r } LIMIT 10" -u anton -p XXX +------------------------+ | r | +------------------------+ | repository:CO_3 | | repository:Reference_1 | | repository:CO_4 |

But with stradog-rb it not works (returns empty result):

require 'stardog' include Stardog sd = stardog("http://XXX:5820/", :user => "onto1", :password => "XXX", :reasoning => "SL") res= sd.query 'onto1', 'SELECT ?r where { PC:PersonalCollection_2 PC:hasResourceByLanguage ?r } LIMIT 10' data = res.body["results"]["bindings"] p data

Other queries that are not depends on reasoning work fine...

colorprint commented 10 years ago

The patch below works to resolve this issue (the reasoning string should be present not only in the headers but in the request string too):

--- ../../orig/stardog-rb/lib/stardog.rb    2014-07-14 23:34:10.689500583 +0400
+++ stardog.rb  2014-07-14 23:32:14.876173624 +0400
@@ -487,6 +487,11 @@
       elsif(params.is_a?(String) && params != "")
         url = "#{url}?#{params}"        
       end
+      
+      if @reasoning && "#{params}".start_with?('query=')
+        url+="&reasoning=#{@reasoning}"
+      end
+
       arguments = {
         :method => method.to_s.downcase.to_sym,
         :url => url,