-
-
Save vhyza/a00d415a70db429b8860 to your computer and use it in GitHub Desktop.
ruby-sparql issue
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
PREFIX ex: <http://example.com/> | |
CONSTRUCT { | |
[] ex:label "Should appear once" . | |
} | |
WHERE { | |
[] a ex:bound . | |
} |
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
PREFIX ex: <http://example.com/> | |
CONSTRUCT { | |
[] ex:label "Should appear once" . | |
} | |
WHERE { | |
OPTIONAL { | |
?s ?p ex:not-bound . | |
} | |
FILTER (!bound(?s)) | |
} |
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
@prefix ex: <http://example.com/> . | |
[] a ex:bound . | |
[] a ex:somethingElse . |
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
source :rubygems | |
gem 'rdf-turtle' | |
gem 'rdf-rdfa' | |
gem 'sparql' | |
gem 'equivalent-xml' |
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 '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