Re: RDF traversal

I have a fair amount of code for working with RDFS and OWL using RdfContext. I created it for a private project, which I can't share directly. I was intended to extract it into a similar Gem to make it more publicly useful. It needs to be re-wored for RDF.rb, and could make use of the rdfs gem as well, as I've repeated some of the inference steps.

I found it useful to consider classes and properties as Terms. I can then provide operations on classes such as #sub_class_of and #sub_class as well as enumerate #properties for a given class. It's also use to use OWL restrictions to create cardinality rules and datatype restrictions. These also need to consider inference rules, which can be fairly difficult; I ended up making some simplifying assumptions to implement this.

For Properties, enumerating #domains and #ranges, also considering inference.

I also created some Ontology Serializers that made use of my Term class to generate pretty cool HTML+RDFa documentation of an Ontology, as well as Turtle/RDFXML versions. This might be better done as a separate Gem or Rails plugin/service.

I made use of this to run validations over documents based on ontologies I've defined for the Connected Media Experience to ensure that they are conformant. Having this in an open-source form could make it much more generally useful.

I'd be happy to work with you on an RDF.rb-based Gem to get this out in a more general way.

Gregg

On Jan 26, 2011, at 4:52 AM, Gabor Ratky wrote:

> 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 21:14:50 UTC