RubyCon v0.8 User Guide

Ben Bongalon
August 13, 2004

 

Downloading RubyCon

You can get the latest release of RubyCon download page.

Installing RubyCon

  1. First, make sure that you have Ruby installed. You can get the latest version via RubyCentral.

  2. Once you have Ruby installed, extract the contents of the RubyCon ZIP file using Winzip or similar tool. You should see a folder named “rubycon” after you unzip the RubyCon package.

If you are using Microsoft Windows, you are done installing RubyCon! Go to the next section Using RubyCon.

If you are using a different operating system, follow the remaining steps to rebuild the concepts and assertions databases.

  1. Open a console window (eg, a Unix shell).

  2. Change your current directory to the "rubycon/db" folder. Make sure you are in the "db" folder and not in "rubycon".

  3. Delete all the files in the "db" subfolder.

  4. Go up one level back to the "rubycon" folder.

  5. Run the Ruby interpreter and enter these commands:
load "rubycon.rb"
rcon = RubyCon.new
rcon.import "predicates.txt"

Bear in mind that the "predicates.txt" file contains over 280,000 assertions, so the import() command may take several minutes to run. You should see an output that looks similar to this:

    irb> load "rubycon.rb"

    Loading relations into memory...
    Loading forward Links into memory...
    Loading backward Links into memory...
    => true

    irb> rcon = RubyCon.new

    => <RubyCon: 43261320>

    irb> rcon.import "predicates.txt"  

    Reading assertions file 'predicates.txt'
    ................................................................................
    ................................................................................
    ................................................................................
    .............................................
    Saving assertions to RubyCon databases...
    Flushing data into relations database...
    Flushing data into ForwardLinks database...
    Flushing data into BackwardLinks database...
    Done. 284511 assertions were imported.
    => nil

Using RubyCon

This is a brief overview of what you can do with RubyCon. A more detailed tutorial will be available in future.

To use RubyCon, you must know some basic Ruby commands. Ruby is simple and fun to learn, and you can find excellent tutorials and resources on Ruby online, such as Programming Ruby. Once you are fairly familiar with Ruby, you can get started.

  1. Open a Ruby shell window. On Windows platforms, you can do this by doubleclicking the IRB icon on your Desktop or run it via Start –> Programs –> Ruby –> Ruby181 –> Ruby Interactive Shell.

  2. In the Ruby shell, change your current directory to the “rubycon” folder and load the "rubycon.rb" file.

    Example:  

    irb> Dir.chdir "c:/work/rubycon"

    irb> load "rubycon.rb"

    irb> rcon = RubyCon.new

Retrieving and inspecting a concept

irb> c1 = rcon.fetch "rainbow"
irb> c1.name

"rainbow"

irb> c1.semanticID

"82438"

irb> c1.forwardLinks

=> [Link78279, Link78280, Link78281, Link78282, Link78283, Link78284, Link137775
, Link137776, Link137777, Link166957, Link166958, Link166959, Link217162, Link21
7163, Link217164, Link217165, Link241417, Link251301, Link251302]

irb> c1.forwardLinks.each {|link| puts link.to_s(true)}

(Link78279 'Do' 'rainbow' 'appear opposite sun during rainfall')
(Link78280 'Do' 'rainbow' 'consist of several band of color')
(Link78281 'Do' 'rainbow' 'happen when it rain')
(Link78282 'Do' 'rainbow' 'have seven colour')
(Link78283 'Do' 'rainbow' 'occur after rain')
(Link78284 'Do' 'rainbow' 'show we visible spectrum of light')
(Link137775 'IsA' 'rainbow' 'multicolored light arc')
(Link137776 'IsA' 'rainbow' 'symbol')
(Link137777 'IsA' 'rainbow' 'visible spectrum')
(Link166957 'LocationOf' 'rainbow' 'at water fountain')
(Link166958 'LocationOf' 'rainbow' 'at waterfall')
(Link166959 'LocationOf' 'rainbow' 'in sky')
(Link217162 'OftenNear' 'rainbow' 'beanie')
(Link217163 'OftenNear' 'rainbow' 'hat')
(Link217164 'OftenNear' 'rainbow' 'propellor')
(Link217165 'OftenNear' 'rainbow' 'toy')
(Link241417 'PartOf' 'rainbow' 'end')
(Link251301 'PropertyOf' 'rainbow' 'beautiful')
(Link251302 'PropertyOf' 'rainbow' 'red')

irb> c1.inspect

=> "#c82438"

irb> c1.inspect(true)

[Concept 82438: 'rainbow'
   Forward Links:
   (Link78279 'Do' 'rainbow' 'appear opposite sun during rainfall')
   (Link78280 'Do' 'rainbow' 'consist of several band of color')
   (Link78281 'Do' 'rainbow' 'happen when it rain')
   (Link78282 'Do' 'rainbow' 'have seven colour')
   (Link78283 'Do' 'rainbow' 'occur after rain')
   (Link78284 'Do' 'rainbow' 'show we visible spectrum of light')
   (Link137775 'IsA' 'rainbow' 'multicolored light arc')
   (Link137776 'IsA' 'rainbow' 'symbol')
   (Link137777 'IsA' 'rainbow' 'visible spectrum')
   (Link166957 'LocationOf' 'rainbow' 'at water fountain')
   (Link166958 'LocationOf' 'rainbow' 'at waterfall')
   (Link166959 'LocationOf' 'rainbow' 'in sky')
   (Link217162 'OftenNear' 'rainbow' 'beanie')
   (Link217163 'OftenNear' 'rainbow' 'hat')
   (Link217164 'OftenNear' 'rainbow' 'propellor')
   (Link217165 'OftenNear' 'rainbow' 'toy')
   (Link241417 'PartOf' 'rainbow' 'end')
   (Link251301 'PropertyOf' 'rainbow' 'beautiful')
   (Link251302 'PropertyOf' 'rainbow' 'red')
   Backward Links:
   (Link178322 'OftenNear' 'beanie' 'rainbow')
   (Link199900 'OftenNear' 'hat' 'rainbow')
   (Link216651 'OftenNear' 'propellor' 'rainbow')
   (Link230030 'OftenNear' 'toy' 'rainbow')
   ]
   => nil

Find the connection between any two concepts

This may take a long time to run in some cases. You can also specify how many le

irb> rcon.findPath "nail", "hammer"

Num nodes visited: 3105
Num results: 7
   RESULTS
   Path 1:
   (Link209496 'OftenNear' 'nail' 'clamp')
   (Link184703 'OftenNear' 'clamp' 'hammer')
   Path 2:
   (Link209497 'OftenNear' 'nail' 'clock')
   (Link185016 'OftenNear' 'clock' 'hammer')
   Path 3:
   (Link209504 'OftenNear' 'nail' 'hammer')
   Path 4:
   (Link209505 'OftenNear' 'nail' 'hand')
   (Link199113 'OftenNear' 'hand' 'hammer')
   Path 5:
   (Link209509 'OftenNear' 'nail' 'metal')
   (Link207954 'OftenNear' 'metal' 'hammer')
   Path 6:
   (Link209511 'OftenNear' 'nail' 'plywood')
   (Link215635 'OftenNear' 'plywood' 'hammer')
   Path 7:
   (Link209513 'OftenNear' 'nail' 'screwdriver')
   (Link220770 'OftenNear' 'screwdriver' 'hammer')
   => [[Link209496, Link184703], [Link209497, Link185016], [Link209504], [Link20950
   5, Link199113], [Link209509, Link207954], [Link209511, Link215635], [Link209513,
   Link220770]]



Retrieving assertions

irb> rcon.match ["Do", "monkey", "eat banana"]

(Link62295 'Do' 'monkey' 'eat banana')
=> [Link62295]

irb> rcon.match ["Do", "monkey", "eat steak"]

[]


irb> rcon.match ["Do", "monkey", /eat/]

(Link62295 'Do' 'monkey' 'eat banana')
(Link62296 'Do' 'monkey' 'eat bug')
(Link62300 'Do' 'monkey' 'like to eat banana')
(Link62307 'Do' 'monkey' 'might like to eat banana')
=> [Link62295, Link62296, Link62300, Link62307]

Adding and deleting assertions

irb> rcon.assert ["Isa", "Coco", "monkey"]

=> Link284512

irb> rcon.match ["Isa", "Coco", //]

(Link284512 'IsA' 'Coco' 'monkey')
=> [Link284512]
irb> rcon.retract ["Isa", "Coco", "monkey"] irb> rcon.match ["Isa", "Coco", //] => []

After you have asserted and/or retracted all the facts you want, make sure to call the RubyCon save() function so that the changes you made get permanently stored in the RubyCon knowledgebase.

irb> rcon.save