# Suggestion for Ruby quiz

**URL:** <https://www.ruby-forum.com/t/suggestion-for-ruby-quiz/55887>\
**Category:** Ruby\
**Created:** [March 24, 2006, 4:24pm UTC](https://www.ruby-forum.com/t/suggestion-for-ruby-quiz/55887 "2006-03-24T16:24:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsme213](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/258eb7/32.png) [@itsme213](https://www.ruby-forum.com/u/itsme213)\
**Post date:** [March 24, 2006, 4:24pm UTC](https://www.ruby-forum.com/t/suggestion-for-ruby-quiz/55887/1 "2006-03-24T16:24:19Z")

</div>

Integration of OWL with Ruby

######################

OWL (Web Ontology Language) has several interesting capabilities,  
including:

- Define a (possibly anonymous) class using property expressions  
DarkChocolate = Dark & base\_material is a Chocolate  
Dark = (any Thing) with brightness = Low
- Class definition can be incremental and federated  
Vehicle = …  
…  
Vehicle = …
- Classification  
Determine if arbitrary object is member of class by checking  
properties
- Equivalent | Disjoint | …  
Assert that two separately defined classes always | never have the  
same  
members
- First-class properties  
Properties are applicable to independent classes (duck typing)  
Properties are namespaced (Ruby 2 forthcoming selector namespace)
- Numerous tools  
There are many (open-source) tools that handle OWL ontologies
- Formal interpretation  
Maps to RDF tuples (subject-predicate-object)  
Makes many (open-source) formal analysis tools applicable

Tons of info on OWL on the web. One tutorial at  
[http://www.cs.man.ac.uk/~horrocks/ISWC2003/Tutorial/](http://www.cs.man.ac.uk/~horrocks/ISWC2003/Tutorial/)

######################

A deep integration of OWL with Ruby would be interesting and potentially  
very useful:

- opening up new kinds of expressiveness in Ruby
- allowing all of Ruby’s power in manipulating OWL
- opening access to OWL and RDF tools.

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](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

######################

There may be some useful Ruby resources already available based on work  
by  
Rich Kilmer.  
[www.daml.org/meetings/2004/05/pi/pdf/InfoEther-Semitar.pdf](http://www.daml.org/meetings/2004/05/pi/pdf/InfoEther-Semitar.pdf)

---

<div class="post-metadata">

**Author:** ![itsme213](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/258eb7/32.png) [@itsme213](https://www.ruby-forum.com/u/itsme213)\
**Post date:** [March 24, 2006, 5:36pm UTC](https://www.ruby-forum.com/t/suggestion-for-ruby-quiz/55887/2 "2006-03-24T17:36:00Z")

</div>

On Mar 24, 2006, at 9:23 AM, itsme213 wrote:

> Integration of OWL with Ruby

This is an interesting idea.

My only concern is: how much work is involved? (I honestly have no  
idea.) Does someone want to email me an implementation off-list with  
details of how long it took you? Could we maybe choose a subset of  
functionality that could be accomplished fairly quickly?

James Edward G. II

---

<div class="post-metadata">

**Author:** ![itsme213](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/258eb7/32.png) [@itsme213](https://www.ruby-forum.com/u/itsme213)\
**Post date:** [March 25, 2006, 2:41am UTC](https://www.ruby-forum.com/t/suggestion-for-ruby-quiz/55887/3 "2006-03-25T02:41:40Z")

</div>

On 3/24/06, Caleb C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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.

Check out Obie’s work-in-progress on this topic. Very cool:  
“Deep Integration of Ruby with Semantic Web Ontologies”  
[http://gigaton.thoughtworks.net/~ofernand1/DeepIntegration.pdf](http://gigaton.thoughtworks.net/~ofernand1/DeepIntegration.pdf)

---

<div class="post-metadata">

**Author:** ![itsme213](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/258eb7/32.png) [@itsme213](https://www.ruby-forum.com/u/itsme213)\
**Post date:** [March 25, 2006, 1:04am UTC](https://www.ruby-forum.com/t/suggestion-for-ruby-quiz/55887/4 "2006-03-25T01:04:55Z")

</div>

On 3/24/06, itsme213 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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  
> [Tutorial on OWL](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.

> 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?
