The State of Rdf in Ruby

The State of RDF in Ruby

Hey, Iaalto, I'm the author of the survey article that you mentioned. I've been thinking about doing a new survey.

A little has changed since I did the original survey, but not much. Here are a couple of things to consider:

  1. ActiveRDF seems to have gone the route of being a JRuby specific library. Several of their adapters are for Java only libraries. Not necessarily a problem, but something to be aware of.
  2. Reddy only has a memory based graph. Again, not necessarily a problem. I wouldn't discount Reddy for that (premature optimization), but I also wouldn't dream of storing billions of triples.
  3. I recently found a new set of Ruby bindings for Redland called RedLeaf. Not sure how mature it is, but it looks like Michael has been working on it for about a year. I hadn't heard of it until recently because it is off-grid (no RubyForge or GitHub project).
  4. I created a project on GitHub called RubyRDF (github.com/pjstadig/rubyrdf/tree/master). It doesn't have a ton of documentation, but it is mostly functional. It has a Sesame compatible adapter with support for transactions. I still have some ideas for future direction, and making it more feature complete, but not a lot of impetus to work on it. I'd welcome any contributions.

Bottom line: If JRuby is not a problem for you, then go with ActiveRDF, it is the most complete and mature. If memory based graph is not a problem, then the next most mature is probably Reddy.

Recommended rdf usage in Ruby on Rails

(For people who are interested in working with actual RDF data, please see The State of RDF in Ruby.)

The short answer to your question: You're looking for respond_to. In general, you'd write something like:

class PeopleController < ApplicationController::Base
respond_to :html, :rdf

def index
@people = Person.all
respond_to do |format|
format.html
format.rdf { convert_to_rdf(@people) }
end
end
end

Of course, you'll have to write 'convert_to_rdf'. You might find that RDF.rb is helpful for that.

What's the preferred RDF toolset for Ruby?

Try RDF.rb (courtesy of Google).

semantic web development using Ruby on Rails

There are already some posts on SO covering this topic. One of the popular ones is The State of RDF in Ruby

Simple example of reification in RDF

"Tolkien wrote Lord of the Rings" can be expressed as a simple statement (subject, predicate, object) like this:

:Tolkien :wrote :LordOfTheRings .

By the way, this is using the Turtle notation for RDF. There are tools online for converting it to RDF/XML.

Using reification, you can have a separate resource representing a statement so you can state additional things about the statement itself, like "Wikipedia said that":

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
_:x rdf:type rdf:Statement .
_:x rdf:subject :Tolkien .
_:x rdf:predicate :wrote .
_:x rdf:object :LordOfTheRings .
_:x :said :Wikipedia .

In real life, you would want to use shared vocabularies, so that whoever or whatever is consuming the RDF will know that you are talking about that Tolkien and that LOTR:

http://dbpedia.org/resource/The_Lord_of_the_Rings

http://dbpedia.org/property/author

http://dbpedia.org/resource/dbppedia/J._R._R._Tolkien



Related Topics



Leave a reply



Submit