Archive for the ‘Semantic Web’ Category

RubyRDF

I remember checking out Dan Brickley‘s RubyRDF library awhile back and having trouble doing much with it. But of course that was a long time ago, so I thought I’d check back in to see if any progress had been made. After all, it’s that Dan Brickley, so you’ve at least got to see what’s there.

Unfortunately, the software was last updated in April 2003, and I suspect this means that it’s been abandoned. As noted in the documentation, RubyRDF is an experimental system and “not production-grade stuff.” Dan also notes later in the page, “I might not do any more work on this.” That’s fair, of course; it seems clear that Dan was pursuing this to scratch an itch, as is the case for a lot of open source projects on the web. But I decided to set this one aside again after a scan of the still-cluttered Wiki page. I guess I’ll check again this time next year, if none of the other RDF libraries for Ruby make it that far.

Rena: A Library for RDF and the Semantic Web

Rena is a new library for working with RDF that seems to be a Ruby port of the popular Jena semantic web framework for Java. As noted by the author, it’s still in the “experimental” stage but already shows some promise.

As with Jena, the basic object model parallels the RDF model. Rena has not yet adopted Jena 2.0′s factory-based approach to creating model instances, so you instead just instantiate the desired model class directly. For example, here’s how to create an in-memory model, add a resource and define some properties for it:

require 'rena' require 'rena/dc'

docURI = “http://www.fxruby.org/doc” docTitle = “FXRuby User’s Guide” docDate = “2004-10-24″

Create an empty Model

model = Rena::MemModel.new

Create the resource

myDoc = model.create_resource(docURI)

Add some properties

myDoc.addproperty(Rena::DC::Title, Rena::PlainLiteral.new(docTitle)) myDoc.addproperty(Rena::DC::Date, Rena::PlainLiteral.new(docDate))

Dump

model.save(STDOUT, :content_type => ‘application/rdf+xml’)

Here, we’re taking advantage of the built-in support for some of the Dublin Core elements. The output of that final call to MemModel#save is the RDF/XML serialization of this model:
<?xml version='1.0'?>
<rdf:RDF xmlns:ns0='http://purl.org/dc/elements/1.1/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description ns0:title='FXRuby User's Guide' ns0:date='2004-10-24' rdf:about='http://www.fxruby.org/doc'/> </rdf:RDF>

I haven’t gotten around to trying out the parsing or querying support yet, but it looks like the author’s goal is to more or less emulate what’s being done with Jena. Hopefully this one will progess quickly.

Domain versus Range

For this brief moment during which I think I get it:

  • the range of a property indicates the type(s) of values it can take on. For example, foaf:homepage has the range foaf:Document, because your homepage must be a Document resource. Another way to say this is that “foaf:Document is the range of foaf:homepage.”
  • the domain of a property indicates the classes of resources that might have one of these properties. For example, the foaf:mbox property has the domain foaf:Agent, because it is Agent resources that have this property. Another way to say this is that “foaf:Agent is the domain of foaf:mbox.”

In Search of the Semantic Web

I’ve been doing a lot of reading over the last few weeks to try to get a better handle on where things stand with the Semantic Web, especially in terms of the enabling technologies (like RDF and OWL) and existing applications. The RDF Primer provides a thorough (a very, very thorough) introduction to RDF which I probably need to re-read soon. And from my limited reading it looks like OWL just builds on top of the RDF foundation by providing an even more precise way to specify the relationships between classes, constraints on properties, and so on. A majority of the software is written in Java, which is no surprise, but it looks as though there are at least a few RDF libraries for Ruby, such as Dan Brickley’s RubyRDF and Dominic Sisneros’s rdf-redland.

In terms of applications, and especially those that are easily accessible to someone like me, I’ve only just started looking around. I spent a lot of time yesterday reading about the Friend of a Friend (FOAF) project, which has the goal of “… creating a Web of machine-readable homepages describing people, the links between them and the things they create and do.” The idea is that you create a special RDF file (typically named foaf.rdf) and place it in some publically accessible place on the web. For example, I’ve now added a button to this blog which links to my FOAF file. By placing a special tag in the metadata of your web page(s) to “advertise” this file, special web crawlers can collect FOAF information about anyone on the web who cares to publish a FOAF file in this fashion. Now I just need to find out how having done that is going to make my life better.