Jena Ruby Hacks

Note: This page presumes that you have a working Jena/Ruby setup. If not, see Setup Jena Ruby for HowTos, etc.

We'll start by running jirb and performing a few setup tasks. Here's some background info:

  • rj is a (Bourne shell) wrapper script for jirb.

  • js.rb is a bit of Ruby code to start up Jena (eg, load jarfiles).

  • song.owl is a simple OWL ontology about songs.

OK; let's get started:

% rj
>> require 'js'
=> true
>> m = Jena.create_model
=> #<Java::ComHpHplJenaOntologyImpl::OntModelImpl:0x6e8e76>
>> m.write(System.out)
    xmlns:owl="" > 
=> #<Java::ComHpHplJenaRdfModelImpl::ModelCom:0xc93cf5>

=> #<Java::ComHpHplJenaOntologyImpl::OntModelImpl:0x6e8e76>
>> m.to_s.size
=> 34613

>> items = %w[ Genre Song Composer Instrument Musician Recording ]
=> ["Genre", "Song", "Composer", "Instrument", "Musician", "Recording"]
>> items.each {|item| Jena.make(m, "{item}") }
=> ["Genre", "Song", "Composer", "Instrument", "Musician", "Recording"]
>> jazz ='')
a type of
my uri is
	hasName ->
>> jazz.hasName = "Jazz Music"
=> "Jazz Music"

This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r3 - 02 Jul 2011, RichMorin
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email