Last active
April 30, 2016 02:33
-
-
Save tallenaz/e199f1191cc656cb8c3d94567d68759a to your computer and use it in GitHub Desktop.
sparql-client examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sparql/client' | |
sparql = SPARQL::Client.new("http://dbpedia.org/sparql") | |
sparql.query("SELECT ?album WHERE { ?album dbp:type 'album'@en ; dbo:artist dbr:The_Beatles . }") | |
# SELECT * WHERE { ?s ?p ?o } OFFSET 100 LIMIT 10 | |
# query = sparql.select.where([:s, :p, :o]).offset(100).limit(10) | |
# query.each_solution { |solution| puts solution.inspect } | |
2.2.4 :055 > query = sparql.select(:album).where([:album, 'dbp:type "album"@en ;', 'dbo:artist dbr:The_Beatles']) | |
=> #<SPARQL::Client::Query:0x3ff07ce42bd4(SELECT ?album WHERE { ?album dbp:type "album"@en ; "dbo:artist dbr:The_Beatles" . })> | |
2.2.4 :056 > query.each_solution { |solution| puts solution.inspect } | |
SPARQL::Client::MalformedQuery: Virtuoso 37000 Error SP030: SPARQL compiler, line 1: syntax error at '"dbo:artist dbr:The_Beatles"' before '.' | |
SPARQL query: | |
define sql:big-data-const 0 SELECT ?album WHERE { ?album dbp:type "album"@en ; "dbo:artist dbr:The_Beatles" . } Processing query SELECT ?album WHERE { ?album dbp:type "album"@en ; "dbo:artist dbr:The_Beatles" . } | |
from /Users/azanella/.rvm/gems/ruby-2.2.4/gems/sparql-client-2.0.0/lib/sparql/client.rb:346:in `block in response' | |
from /Users/azanella/.rvm/gems/ruby-2.2.4/gems/sparql-client-2.0.0/lib/sparql/client.rb:687:in `call' | |
from /Users/azanella/.rvm/gems/ruby-2.2.4/gems/sparql-client-2.0.0/lib/sparql/client.rb:687:in `block in request' | |
from /Users/azanella/.rvm/gems/ruby-2.2.4/gems/sparql-client-2.0.0/lib/sparql/client.rb:683:in `times' | |
from /Users/azanella/.rvm/gems/ruby-2.2.4/gems/sparql-client-2.0.0/lib/sparql/client.rb:683:in `request' | |
from /Users/azanella/.rvm/gems/ruby-2.2.4/gems/sparql-client-2.0.0/lib/sparql/client.rb:343:in `response' | |
from /Users/azanella/.rvm/gems/ruby-2.2.4/gems/sparql-client-2.0.0/lib/sparql/client.rb:304:in `query' | |
from /Users/azanella/.rvm/gems/ruby-2.2.4/gems/sparql-client-2.0.0/lib/sparql/client.rb:270:in `block in call_query_method' | |
from /Users/azanella/.rvm/gems/ruby-2.2.4/gems/sparql-client-2.0.0/lib/sparql/client/query.rb:411:in `result' | |
from /Users/azanella/.rvm/gems/ruby-2.2.4/gems/sparql-client-2.0.0/lib/sparql/client/query.rb:404:in `each_solution' | |
from (irb):56 | |
from /Users/azanella/.rvm/rubies/ruby-2.2.4/bin/irb:11:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment