Getting the wordnet gem, version 0.0.5, working is a little tricky at the moment. It's being rewritten but isn't released yet and the dbd gem is in a similar state.
These steps got it working for me on OS X Lion and MRI 1.8.7. On 1.9.2 convertdb.rb segfaults.
Download WordNet from http://wordnet.princeton.edu/wordnet/download/current-version/
$ ./configure
$ make
$ make install
This uses homebrew (http://mxcl.github.com/homebrew/). If you use a different package manager then you will have to adjust the --with-db-dir below.
$ brew install berkeley-db
$ git clone https://github.com/knu/ruby-bdb
$ cd ruby-bdb
$ git checkout 6aa8054e022fa38055fd441de98b65fd392b8dcb
$ ruby extconf.rb --with-db-dir=/usr/local/Cellar/berkeley-db/5.1.19
$ make
$ make install
$ gem install wordnet
$ gem which wordnet
$ cd your/wordnet/path
$ ruby convertdb.rb
$ mv ruby-wordnet/ `ruby -e "require 'rbconfig'; print Config::CONFIG['datadir']"`
$ irb
> require 'rubygems'
> require 'wordnet'
> lex = WordNet::Lexicon.new
> frog = lex.lookup_synsets('frog', WordNet::Noun)
> frog.first.hypernyms.first.overview
=> "amphibian [noun] -- (cold-blooded vertebrate typically living on land but breeding in water; aquatic larvae undergo metamorphosis into adult form)"
Same here. However, when I run my code for looking up synsets (lookup_synsets), it throws me the following error:
.rvm/gems/ruby-1.9.2-p290/gems/wordnet-0.0.5/lib/wordnet/synset.rb:309:in
'initialize': uninitialized constant WordNet::Synset::Sync (NameError) from .rvm/gems/ruby-1.9.2-p290/gems/wordnet-0.0.5/lib/wordnet/lexicon.rb:233:in
new'from .rvm/gems/ruby-1.9.2-p290/gems/wordnet-0.0.5/lib/wordnet/lexicon.rb:233:in
block in lookup_synsets_by_key' from .rvm/gems/ruby-1.9.2-p290/gems/wordnet-0.0.5/lib/wordnet/lexicon.rb:227:in
each'from .rvm/gems/ruby-1.9.2-p290/gems/wordnet-0.0.5/lib/wordnet/lexicon.rb:227:in
lookup_synsets_by_key' from .rvm/gems/ruby-1.9.2-p290/gems/wordnet-0.0.5/lib/wordnet/lexicon.rb:214:in
lookup_synsets'from /Aptana Studio 3 Workspace/NLP_Test_0.1/wordnetBasedSimilarity.rb:43:in
compareStrings' from /Aptana Studio 3 Workspace/NLP_Test_0.1/wordnetBasedSimilarity.rb:404:in
/Aptana Studio 3 Workspace/NLP_Test_0.1/wordnetBasedSimilarity.rb: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
-- control frame ----------
c:0001 p:0000 s:0002 b:0002 l:000308 d:000308 TOP
-- C level backtrace information -------------------------------------------
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
Edit: The lookup code works fine while running it from the irb console.