- From: Gabor Ratky <gabor@secretsaucepartners.com>
- Date: Wed, 26 Jan 2011 13:52:18 +0100
- 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 UTC