1. Michael Granger
  2. Ruby-WordNet
  3. Issues
Issue #2 resolved

uninitialized constant WordNet::Lexicon

Harold Figueroa
created an issue

After successfully installing the gem (log below). I go into IRB and try to create a lexicon and it fails. The basic NameError also below. Any thoughts? Thanks

As a sidenote. I prefer the Github issue reporting tools, but these seem to be disabled for the project copy there.

(IRB LOG)
1.9.3p362 :002 > require 'wordnet' 
 => true 
1.9.3p362 :003 > lex = WordNet::Lexicon.new 
NameError: uninitialized constant WordNet::Lexicon

(INSTALL LOG)

$ gem install wordnet-defaultdb
Fetching: sequel-3.48.0.gem (100%)
Successfully installed sequel-3.48.0
Fetching: wordnet-1.0.0.gem (100%)

If you don't already have a WordNet database installed somewhere,
you'll need to either download and install one from:

   http://wnsql.sourceforge.net/

or just install the 'wordnet-defaultdb' gem, which will install
the SQLite version for you.

Successfully installed wordnet-1.0.0
Fetching: wordnet-defaultdb-1.0.1.gem (100%)
Successfully installed wordnet-defaultdb-1.0.1
Parsing documentation for sequel-3.48.0
Installing ri documentation for sequel-3.48.0
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for wordnet-1.0.0
Installing ri documentation for wordnet-1.0.0
Parsing documentation for wordnet-defaultdb-1.0.1
Installing ri documentation for wordnet-defaultdb-1.0.1
3 gems installed

Comments (4)

  1. Michael Granger repo owner

    Very strange. Here's my session doing the same thing just now:

    $ gem install wordnet-defaultdb
    Fetching: sequel-3.48.0.gem (100%)
    Successfully installed sequel-3.48.0
    Fetching: wordnet-1.0.0.gem (100%)
    
    If you don't already have a WordNet database installed somewhere,
    you'll need to either download and install one from:
    
       http://wnsql.sourceforge.net/
    
    or just install the 'wordnet-defaultdb' gem, which will install
    the SQLite version for you.
    
    Successfully installed wordnet-1.0.0
    Fetching: sqlite3-1.3.7.gem (100%)
    Building native extensions.  This could take a while...
    Successfully installed sqlite3-1.3.7
    Fetching: wordnet-defaultdb-1.0.1.gem (100%)
    Successfully installed wordnet-defaultdb-1.0.1
    4 gems installed
    
    $ irb
    2.0.0p195 :001 > require 'wordnet'
     => true
    2.0.0p195 :002 > w = WordNet::Lexicon.new
     => #<WordNet::Lexicon:0x7fdc149779b0 sqlite:/Users/mgranger/.rvm/gems/ruby-2.0.0-p195@temp/gems/wordnet-defaultdb-1.0.1/data/wordnet-defaultdb/wordnet30.sqlite>
    2.0.0p195 :003 > w[:shoe]
     => #<WordNet::Synset:0x7fdc14c3d348 {102890940} 'brake shoe, shoe, skid' (noun): [noun.artifact] a restraint provided when the brake linings are moved hydraulically against the brake drum to retard the wheel's rotation>
    

    So it works for some setups. Let's figure out why it doesn't work for you.

    From a shell, can you do: gem list -l wordnet, and from irb:

    require 'wordnet'
    puts $LOADED_FEATURES.grep(/wordnet/i)
    

    ...and post the output? That'll at least give us an idea of where the gem is, and what parts are being loaded.

    Thanks for reporting this! Sorry you don't like the tracker here, but Github doesn't support Mercurial, and I'd rather have the tracker in the same place as the repo. :)

  2. Harold Figueroa reporter

    Thanks for the quick response and for the suggested approach.

    As I started working through it, the problem was obvious, a namespace clash with a somewhat dated, unused, and forgotten gem rwordnet, which was loading when 'wordnet' was required.

    1.9.3p362 :002 > puts $LOADED_FEATURES.grep /wordnet/i
    /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-p362/gems/rwordnet-0.1.3/lib/wordnet/pointer.rb
    /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-p362/gems/rwordnet-0.1.3/lib/wordnet/wordnetdb.rb
    /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-p362/gems/rwordnet-0.1.3/lib/wordnet/index.rb
    /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-p362/gems/rwordnet-0.1.3/lib/wordnet/lemma.rb
    /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-p362/gems/rwordnet-0.1.3/lib/wordnet/pointers.rb
    /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-p362/gems/rwordnet-0.1.3/lib/wordnet/pos.rb
    /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-p362/gems/rwordnet-0.1.3/lib/wordnet/synset.rb
    /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-p362/gems/rwordnet-0.1.3/lib/wordnet.rb
    

    Further confirmation,

    $ gem list | grep word
    rwordnet (0.1.3)
    wordnet (1.0.0)
    wordnet-defaultdb (1.0.1)
    

    Removed and the problem is fixed!

    1.9.3p362 :002 > require 'wordnet' 
     => true 
    1.9.3p362 :003 > w = WordNet::Lexicon.new
     => #<WordNet::Lexicon:0x7feee3cabf00 sqlite:/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-p362/gems/wordnet-defaultdb-1.0.1/data/wordnet-defaultdb/wordnet30.sqlite> 
    1.9.3p362 :004 > w[:sock]
     => #<WordNet::Synset:0x7feee3d4de68 {104254777} 'sock' (noun): [noun.artifact] hosiery consisting of a cloth covering for the foot; worn inside the shoe; reaches to between the ankle and the knee> 
    1.9.3p362 :005 > 
    

    Thanks again!

  3. Log in to comment