# Ruby classifier

**URL:** <https://www.ruby-forum.com/t/ruby-classifier/90366>\
**Category:** Ruby\
**Created:** [March 28, 2007, 6:00am UTC](https://www.ruby-forum.com/t/ruby-classifier/90366 "2007-03-28T06:00:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryo\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/85e7bf/32.png) [@Ryo\_F](https://www.ruby-forum.com/u/Ryo_F)\
**Post date:** [March 28, 2007, 6:00am UTC](https://www.ruby-forum.com/t/ruby-classifier/90366/1 "2007-03-28T06:00:23Z")

</div>

I tried installing ruby classifier using  
sudo gem install classifier  
but when I try to use classifier I get

irb(main):001:0\> require “classifier”  
LoadError: no such file to load – classifier  
from (irb):1:in `require’  
from (irb):1

What am I doing wrong? Thank you.

---

<div class="post-metadata">

**Author:** ![Ryo\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/85e7bf/32.png) [@Ryo\_F](https://www.ruby-forum.com/u/Ryo_F)\
**Post date:** [March 28, 2007, 6:09am UTC](https://www.ruby-forum.com/t/ruby-classifier/90366/2 "2007-03-28T06:09:57Z")

</div>

On 3/28/07, Ryo F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

Didja try  
require ‘rubygems’  
require ‘classifier’

?

---

<div class="post-metadata">

**Author:** ![Ryo\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/85e7bf/32.png) [@Ryo\_F](https://www.ruby-forum.com/u/Ryo_F)\
**Post date:** [March 28, 2007, 7:15am UTC](https://www.ruby-forum.com/t/ruby-classifier/90366/3 "2007-03-28T07:15:06Z")

</div>

Ah, whoops, that part is fixed now. But when to add items to the LSI  
classifier, I get:

> > lsi.add\_item( “This is a turtle.”, :turtle )  
> > =\> nil  
> > lsi.add\_item( “This is a cuckoo.”, :cuckoo )  
> > ArgumentError: wrong number of arguments (1 for 0)  
> > from  
> > /usr/local/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/lsi/content\_node.rb:37:in  
> > `initialize’  
> > …

i.e., I get these “wrong number of arguments” errors as soon as I try to  
add more than one item.

Any idea about this?

Logan C. wrote:

> On 3/28/07, Ryo F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > 
> 
> Didja try  
> require ‘rubygems’  
> require ‘classifier’
> 
> ?

---

<div class="post-metadata">

**Author:** ![Ryo\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/85e7bf/32.png) [@Ryo\_F](https://www.ruby-forum.com/u/Ryo_F)\
**Post date:** [April 10, 2007, 8:54pm UTC](https://www.ruby-forum.com/t/ruby-classifier/90366/4 "2007-04-10T20:54:03Z")

</div>

Dan and Colin,

The current version of Classifier’s LSI is kind of broken. It was  
half in development ages ago and for whatever reason the “stable”  
version got merged with a half-working dev version. For a number of  
reasons (which I’ll omit), development stalled and it wasn’t cleaned  
up.

I wasn’t involved directly with the main development of Classifier,  
but I did have some involvement with some of the not-so-implemented  
ideas. I’ve been extremely busy for a couple months, but sometime  
soon I hope to smooth over some of the LSI issues to get it stable  
again.

I’ll look into the exact error you both are posting - if it’s  
something workaroundable I’ll let you know.

Cameron

---

<div class="post-metadata">

**Author:** ![Ryo\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/85e7bf/32.png) [@Ryo\_F](https://www.ruby-forum.com/u/Ryo_F)\
**Post date:** [April 7, 2007, 7:34pm UTC](https://www.ruby-forum.com/t/ruby-classifier/90366/5 "2007-04-07T19:34:02Z")

</div>

I’ve spent a couple of days trying to get LSI Classifer to work. The  
Bayesian library works fine (and is fun), but LSI is not working for me.  
I have the GSL installed and the ruby-gsl wrapper, which seem to be  
working fine. However, I get the same error as mentioned in the previous  
post. The error occurs as the 2nd item is added to the index. It occurs  
somewhere within the rebuild\_index procedure. If auto\_index is switched  
off, items can be added infinitum. Please help :S

#--------test script

require ‘rubygems’  
require ‘gsl’  
require ‘classifier’  
require ‘stemmer’

lsi = Classifier::LSI.new  
strings = [[“This text deals with dogs. Dogs.”, :dog],  
["This text involves dogs too. Dogs! ", :dog],  
[“This text revolves around cats. Cats.”, :cat],  
[“This text also involves cats. Cats!”, :cat],  
[“This text involves birds. Birds.”,:bird]]  
strings.each {|x| lsi.add\_item x.first, x.last}

lsi.search(“dog”, 3)

# returns =\> [“This text deals with dogs. Dogs.”, "This text involves

dogs too  
. Dogs! ",

# “This text also involves cats. Cats!”]

lsi.find\_related(strings[2], 2)

# returns =\> [“This text revolves around cats. Cats.”, "This text also

involve  
s cats. Cats!"]

lsi.classify “This text is also about dogs!”

# returns =\> :dog

#--------error

/usr/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/extensions/string.rb:6:Warning:  
require\_gem is obsolete. Use gem instead.  
/usr/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/lsi/content\_node.rb:37:in  
`initialize': wrong number of arguments (1 for 0) (ArgumentError) from /usr/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/lsi/content_node.rb:37:in `new’  
from  
/usr/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/lsi/content\_node.rb:37:in  
`raw_vector_with' from /usr/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/lsi.rb:123:in `build\_index’  
from  
/usr/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/lsi.rb:123:in  
`collect' from /usr/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/lsi.rb:123:in `build\_index’  
from  
/usr/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/lsi.rb:65:in  
`add_item' from lsitest.rb:12 from lsitest.rb:12:in `each’  
from lsitest.rb:12

Dan

Colin B. wrote:

> Ah, whoops, that part is fixed now. But when to add items to the LSI  
> classifier, I get:
> 
> > > lsi.add\_item( “This is a turtle.”, :turtle )  
> > > =\> nil  
> > > lsi.add\_item( “This is a cuckoo.”, :cuckoo )  
> > > ArgumentError: wrong number of arguments (1 for 0)  
> > > from  
> > > /usr/local/lib/ruby/gems/1.8/gems/classifier-1.3.0/lib/classifier/lsi/content\_node.rb:37:in  
> > > `initialize’  
> > > …
> 
> i.e., I get these “wrong number of arguments” errors as soon as I try to  
> add more than one item.
> 
> Any idea about this?
> 
> Logan C. wrote:
> 
> > On 3/28/07, Ryo F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > 
> > > 
> > 
> > Didja try  
> > require ‘rubygems’  
> > require ‘classifier’
> > 
> > ?

---

<div class="post-metadata">

**Author:** ![Ryo\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/85e7bf/32.png) [@Ryo\_F](https://www.ruby-forum.com/u/Ryo_F)\
**Post date:** [April 10, 2007, 9:43pm UTC](https://www.ruby-forum.com/t/ruby-classifier/90366/6 "2007-04-10T21:43:22Z")

</div>

Cameron McBride wrote:

> Dan and Colin,
> 
> The current version of Classifier’s LSI is kind of broken. It was  
> half in development ages ago and for whatever reason the “stable”  
> version got merged with a half-working dev version. For a number of  
> reasons (which I’ll omit), development stalled and it wasn’t cleaned  
> up.
> 
> I wasn’t involved directly with the main development of Classifier,  
> but I did have some involvement with some of the not-so-implemented  
> ideas. I’ve been extremely busy for a couple months, but sometime  
> soon I hope to smooth over some of the LSI issues to get it stable  
> again.
> 
> I’ll look into the exact error you both are posting - if it’s  
> something workaroundable I’ll let you know.
> 
> Cameron

Cameron, Thanks for your reply. I appreciate the difficulty in  
maintaining these things, so thanks for any input you can provide. If I  
find a fix, I’ll post it here.

Regards  
Dan
