Created
February 1, 2011 18:33
-
-
Save bhuga/806334 to your computer and use it in GitHub Desktop.
Updates to SPARQL client to allow parsing with other tools, if so wished.
This file contains hidden or 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' | |
require 'rest_client' | |
sparql = SPARQL::Client.new("http://dbpedia.org/sparql") | |
# existing functionality: | |
p sparql.query("select distinct ?Concept where {[] a ?Concept}").inspect | |
# now equivalent to: | |
response = RestClient.post 'http://dbpedia.org/sparql', { :query => "select distinct ?Concept where {[] a ?Concept}" }, :content_type => 'application/x-www-form-urlencoded', :accept => 'application/sparql-results+json' | |
p SPARQL::Client.parse_json_bindings(response) | |
# also now equivalent to: | |
response = sparql.response("select distinct ?Concept where {[] a ?Concept}", SPARQL::Client::ACCEPT_JSON ) | |
puts responset.body | |
p SPARQL::Client.parse_json_bindings(response.body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment