Skip to content

Instantly share code, notes, and snippets.

@vhyza

vhyza/Gemfile Secret

Last active December 16, 2015 15:49
Show Gist options
  • Save vhyza/a00d415a70db429b8860 to your computer and use it in GitHub Desktop.
Save vhyza/a00d415a70db429b8860 to your computer and use it in GitHub Desktop.
ruby-sparql issue
PREFIX ex: <http://example.com/>
CONSTRUCT {
[] ex:label "Should appear once" .
}
WHERE {
[] a ex:bound .
}
PREFIX ex: <http://example.com/>
CONSTRUCT {
[] ex:label "Should appear once" .
}
WHERE {
OPTIONAL {
?s ?p ex:not-bound .
}
FILTER (!bound(?s))
}
@prefix ex: <http://example.com/> .
[] a ex:bound .
[] a ex:somethingElse .
source :rubygems
gem 'rdf-turtle'
gem 'rdf-rdfa'
gem 'sparql'
gem 'equivalent-xml'
require 'rdf/turtle'
require 'rdf/rdfa'
require 'sparql'
repository = RDF::Repository.load(File.expand_path('foo.ttl', File.dirname(__FILE__)), format: :turtle)
query_files = Dir[File.expand_path('*.rq', File.dirname(__FILE__))]
query_files.each do |query_file|
puts "* Processing file #{query_file.split('/').last}", "="*50, ""
query = File.read(query_file)
puts query, "", "-"*50
solutions = SPARQL.execute(query, repository)
puts "found #{solutions.size} #{solutions.size > 1 || solutions.size == 0 ? "results" : "result"}", (solutions.dump(:turtle) rescue solutions.inspect), "", "="*50, ""
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment