ruby-rdf / rdf-sesame Goto Github PK
View Code? Open in Web Editor NEWRDF.rb plugin for accessing Sesame 2.0-compatible repositories.
Home Page: http://rubygems.org/gems/rdf-sesame
License: The Unlicense
RDF.rb plugin for accessing Sesame 2.0-compatible repositories.
Home Page: http://rubygems.org/gems/rdf-sesame
License: The Unlicense
This adapter is not yet optimized for RDF.rb 0.2.x's enhanced query APIs; this may adversely affect triple pattern query performance.
This should be addressed in an upcoming version.
With the RDF::Repository, I can set a context with the #set_context method. After than, every statement I'm going to insert into the repository will be assigned this context.
But when I delete statements from the repository, the context that is used to delete the statements is the one already assigned to the statement (RDF::Statement#context= or #graph=). So the two operations are not symmetric at all.
I'm going to do a PR in a few to adjust that behavior.
I can't get the contexts used inside a Sesame repository anymore. It loops infinitely until the stack level is too deep and it raises an error. It does the same when I try to list the statements using '#each_statement".
The code to trigger this behavior is pretty simple:
server = RDF::Sesame::Server.new(db_url)
repository = server.repository(repository_name')
# either this
repository.each_statement do |s| # <= each starts the infinite loop
puts s.inspect
end
# or this
puts repository.graph_names.inspect
I'm pushing a PR in a few minutes, I'll reference this issue.
Currently, connections are internally implemented using Net::HTTP
from Ruby's standard library, and connections are always transient, i.e. they do not persist from one request to the next and must always be reopened when used.
We should implement support for persistent Keep-Alive connections as a future improvement.
This adapter does not contain any SPARQL support at present. To use a Sesame endpoint with SPARQL, see the SPARQL::Client
gem.
Once the SPARQL client reaches a beta-quality level, we should add it as a dependency and have RDF::Sesame::Repository
inherit from SPARQL::Client::Repository
.
See https://github.com/ruby-rdf/rdf-sesame/blob/develop/lib/rdf/sesame/repository.rb#L311
Today the detection of SPARQL Construct to define the default format to text/plain is quite ugly (based on regular expression /bconstruct/b). It should be removed or enhance.
This adapter is not yet optimized for RDF.rb 0.2.x's bulk-operation APIs, meaning that statement insertions and deletions are currently performed one by one; this may affect the performance of loading large datasets into Sesame.
This should be addressed in an upcoming version.
Bug inserting RDF-XML based graphs into repositories.
I am able to insert NTriple based readers into a Sesame repository. However, RDFXML ones cannot be inserted. Here's what I've been trying:
require 'rdf'
require 'rdf/sesame'
require 'rdf/rdfxml'
repository = RDF::Sesame::Repository.new('http://localhost:8080/openrdf-sesame/repositories/test')
reader = RDF::NTriples::Reader.new(File.read(RAILS_ROOT + '/public/doap.nt'))
repository.clear
repository.insert(reader)
repository.count
reader = RDF::RDFXML::Reader.new(File.read(RAILS_ROOT + '/public/doap.xml'))
repository = RDF::Sesame::Repository.new('http://localhost:8080/openrdf-sesame/repositories/test')
repository.clear
repository.insert(reader)
repository.count
stream = File.open(RAILS_ROOT + '/public/doap.xml')
graph = RDF::Graph.new
RDF::RDFXML::Reader.new(stream).each { |s| graph << s }
puts graph.count
repository.clear
repository.insert(graph.to_a)
repository.count
repository.clear
repository.insert(*graph.to_a)
repository.count
repository.clear
repository<<graph.to_rdf
repository.count
repository<<graph
repository.insert(graph)
repository.insert(graph.to_ntriples)
repository.insert(_graph.to_ntriples)
graph.each { |s| repository << s }
graph.each { |s| repository.insert(_s) }
graph.each { |s| repository.insert(s) }
stream = File.open(RAILS_ROOT + '/public/doap.xml')
graph = RDF::Graph.new
RDF::RDFXML::Reader.new(stream).each { |s| graph << s }
reader = RDF::NTriples::Reader.new(graph.to_ntriples)
repository.insert(reader)
I am able to get this to work with the RDF Context gem:
require 'rdf'
require 'rdf/sesame'
require 'rdf_context'
url = "http://localhost:8080/openrdf-sesame/repositories/test"
repository = RDF::Sesame::Repository.new(url)
f = File.open(RAILS_ROOT + '/public/rdf.xml')
graph = RdfContext::Graph.new
graph.parse(f.read, nil, :type => :rdfxml)
statements = RDF::NTriples::Reader.new(graph.to_ntriples)
repository.insert(*statements)
repository.count
repository.clear!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.