From: Caleb Clausen Date: 2006-03-25T09:04:48+09:00 Subject: Re: Suggestion for Ruby quiz On 3/24/06, itsme213 wrote: > Integration of OWL with Ruby > > ###################### > > OWL (Web Ontology Language) has several interesting capabilities, including: Aside from the quizzy possibilities, you've made me curious about OWL itself. I've never heard of OWL before, but it seems pretty interesting. I'm trying to learn more now. Part of my interest is that OWL resembles in some ways my pattern-matching language, Reg. It seems that they address somewhat different areas, but there is perhaps quite a lot of overlap. From what I'm seeing right now, OWL is, unfortunately, XML-based. > - Define a (possibly anonymous) class using property expressions > DarkChocolate = Dark & base_material is a Chocolate > Dark = (any Thing) with brightness = Low So, in Reg this might be: Dark = item_that.brightness==Low DarkChocolate = item_that.base_material.is_a?(Chocolate) & Dark alternately: DarkChocolate = -{:brightness=>Low, :base_material=>Chocolate} > - Class definition can be incremental and federated > Vehicle = .... > ... > Vehicle = .... Uhh, you left too much out for me to make much sense of this.... but it sounds like Ruby's open classes? > - Classification > Determine if arbitrary object is member of class by checking properties How would this differ from the DarkChocolate example above? > - Equivalent | Disjoint | ... > Assert that two separately defined classes always | never have the same > members It sounds cool. And I have absolutely no idea how it could be done in my system. > Tons of info on OWL on the web. One tutorial at > http://www.cs.man.ac.uk/~horrocks/ISWC2003/Tutorial/ A page full of links to powerpoint and pdf files. I'm too ill today to want to deal with that.... maybe tomorrow. I'll google about a bit for this. > One might even find some intriguing links between some of OWL's features and > Ruby with duck typing, open classes, method_missing, dynamic mix-ins, etc. > (See http://gigaton.thoughtworks.net/~ofernand1/DeepIntegration.pdf) > > An example of integrating OWL and Ruby, adapted from the above URL: > > class TeachersChild < OWL::Thing > > defined_with_query some_expression_or_block_or_string > > def misbehave > raise "Teacher's kids never misbehave" > end > > end > > obj1 = OWL::Thing.new (properties which may qualify as TeachersChild) > > obj1.misbehave # dynamically pick up TeachersChild#misbehave > > ExternalOWLTool.process obj1 # external reasoning tools In Reg, classes (in the OO sense) and patterns (queries on objects) aren't the same thing. So, this example really blows my mind. This is really cool, and I like it. But I'm a bit unclear about this line: obj1.misbehave Am I correct in assuming that it raises the exception if TeachersChild===obj1? If so, then what happens if obj1 is also a ProblemChild that (mis)behaves differently?