Saturday, September 29, 2007

RDF in Ruby

I've been meaning to have a play with Ruby for a while now, and I have a project in mind that a dynamic language would be perfectly suited for. The trouble is, it's an ontology processing project. I don't really want to go to the trouble of building the supporting infrastructure myself (been there, done that). So I've been looking for ontology handling, or at least RDF handling libraries for Ruby. It's not exactly a large field. There are some largely moribund projects, and two active projects I could find: ActiveRDF and Redland. Redland is Dave Beckett's C API for RDF, which comes with bindings to several other languages, including Perl, Python and Ruby. It is, by design, just an RDF API: OWL processing will have to be built on top. ActiveRDF is a meta-wrapper: it provides a common Ruby API to other stores, including Redland, Sesame and Jena (in jRuby only). I probably should spend some more time with ActiveRDF, but some of the "Why do you and why don’t you …" answers on the FAQ mean that my application isn't going to fill all that well with their assumptions. So it looks like my choices are to use the Redland API from generic Ruby, or stick with jRuby and call the Jena API.

I decided to have a go with Redland, since I know Dave and it will be interesting to see up-close how another RDF API works. First hurdle, then, was sorting out the install. I'm working on Fedora 7 at home. This does ship with a version of Redland (though neither of the RPM versions available on Dave's web site), but not the Ruby bindings. Trying to install results in version incompatibility with the Fedora versions of Redland. Trying to install redland-1.0.6-1.i386.rpm results in unmet dependencies with and (Fedora 7 has .4 and .5, respectively). However, installing the source RPM's from and rebuilding the binary RPM files solved that problem. Next issue: redland-bindings would not, however, build correctly from source (reporting this problem:
error: Installed (but unpackaged) file(s) found:
However, once I'd got the updated RPM's built for redland, rasqal and raptor I could simply install Dave's pre-built redland-ruby- Phew. OK, so this is side-stepping rather than solving the underlying problem, but hey, life is short.

The good news is that the demo program example.rb worked first time, and seemed quite nippy without the overhead of starting up a JVM. Right, now time to get on with some coding! ruby, rdf, semantic-web


Ted said...

Thanks for the nice writeup. I'm trying to decide whether Python or Ruby is better for a project that will likely involve rules and RDFS reasoning (probably not OWL..)

Do you have any comments a few months after your first try about Ruby + Redland?

Jason Morrison said...

Yes, thank you for the writeup! I would also love to hear about your experiences, now that a few months have passed.

Also, if anyone reading happens to have had an issue getting Redland going on Ubuntu using apt-get, I wrote up my experience installing Redland no Ubuntu from source.


sf said...

Hm, no email on the blog to contact you at. Guess I'll just do it here! :)

So, since this post, have you had any more experience with RDF in Ruby or Python? Your assessment of RDF in Ruby as moribund lines up with my research and this seem like a major oversight!

My understanding (esp. from DIGging around in the W3C) is that Python is receiving much more of an infusion of RDF support ( ) possibly because TBL uses Python. ( ).