W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > January 2011

RDF traversal

From: Gabor Ratky <gabor@secretsaucepartners.com>
Date: Wed, 26 Jan 2011 13:52:18 +0100
Message-Id: <AA1A9C5B-FB6E-4F31-A6FB-DC96CE0963B1@secretsaucepartners.com>
To: public-rdf-ruby@w3.org
Hi semantic ruby peeps,

Do you know if there was any existing gem / plugin or someone was already working on something for traversing ontologies along RDF/RDFS/OWL predicates, such as RDF::RDFS.subClassOf. I've started implementing a few and could later extract them into a separate rdf-owl or similar gem maybe with an appropriate object model (Property, Instance classes, RDF::OWL::Class#instances, #subclasses, #parent, etc.). I wouldn't want to be working on this if this functionality was already available somewhere.

One simple example would be:

class RDF::Graph
   def subclasses(options={})
     enum_subclass(options[:class], options.key?(:deep))
   end

   def each_subclass(parent, deep=true, &block)
     if block_given?
       self.query(:predicate => RDF::RDFS.subClassOf, :object => parent).each_subject do |subject|
         block.call(subject)
         each_subclass(subject, deep, &block) if deep
       end
     end
     enum_subclass(parent, deep)
   end

   def enum_subclass(parent, deep=true)
     enum_for(:each_subclass, parent, deep)
   end
   alias_method :enum_subclasses, :enum_subclass
end

Any ideas?

Cheers--
Gabor
Received on Wednesday, 26 January 2011 20:40:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 26 January 2011 20:40:06 GMT