This is a question from Ruby Cookbook by Lucas Carlson & Leonard
Richardson, Oreilly Publication. Recipe number 1.20 in Chapter 1 on
As instructed in the book, I am trying to use the classifer gem to do
Bayesian Analysis. It advises me to install the classifer gem by using
the ‘gem install classifer’ command. gem asks me if I want to install
the stemmer gem as a dependency, I say yes and it installs it.
Next, I am trying to check if everything works by running a snippet out
of the README file from the classifer gem install directory as follows:
test.rb which contains the following lines of code:
require 'classifier' b = Classifier::Bayes.new 'Interesting', 'Uninteresting' b.train_interesting "here are some good words. I hope you love them" b.train_uninteresting "here are some bad words, I hate you" b.classify "I hate bad words and you" # returns 'Uninteresting'
When I run it, I get the following error:
Notice: for 10x faster LSI support, please install
method_missing': undefined methodstem’ for “here”:String
each' from c:/ruby/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/extensions/word_hash.rb:32:inword_hash_for_words’
word_hash' from c:/ruby/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/bayes.rb:26:intrain’
method_missing' from c:/ruby/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/bayes.rb:95:ineval’
method_missing' from c:/ruby/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/bayes.rb:95:ineach’
Exit code: 1
I contacted the author, Lucas Carlson, concerning this and he advised me
to install the stemmer gem by doing ‘gem install stemmer’ command. I
have done that already by answering Yes to the question by gem installer
if the dependency gem should be installed? I can also see the stemmer
gem that has been installed in the gems directory. Mind you, this
happens both in Linux and Windows operating systems, therefore, there is
something that I must be overlooking. I haven’t heard back from the
author. Therefore, I am posting this question here on the forum to see
if anyone can help.
Thanks in advance.