Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zombiewriter crashing with an error in Classifier Reborn #5

Closed
masdc opened this issue Apr 14, 2017 · 2 comments
Closed

Zombiewriter crashing with an error in Classifier Reborn #5

masdc opened this issue Apr 14, 2017 · 2 comments
Assignees

Comments

@masdc
Copy link

masdc commented Apr 14, 2017

Hi. I was trying to use your ZombieWriter software in Windows, but unfortunately is not working.

require 'zombie_writer'
zombie = ZombieWriter::Randomization.new

zombie.add_string(content: "This is filler text that I invented.This is also a paragraph that could be used")
zombie.add_string(content: "This post is amazing. Please take a look")
zombie.add_string(content: "For all sports fan, you must watch this video. Hey you have to check this out.")


array = zombie.generate_articles


File.open("e:/temp/articles.md", "w+") do |f|
  array.each { |article| f.puts("#{article}\n- - -\n\n") }
end

I always get the following error:

C:/Ruby23/lib/ruby/gems/2.3.0/gems/classifier-reborn-2.1.0/lib/classifier-reborn/lsi.rb:309:in sort': comparison of Float with NaN failed (ArgumentError) from C:/Ruby23/lib/ruby/gems/2.3.0/gems/classifier-reborn-2.1.0/lib/classifier-reborn/lsi.rb:309:in build_reduced_matrix'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/classifier-reborn-2.1.0/lib/classifier-reborn/lsi.rb:143:in build_index' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/classifier-reborn-2.1.0/lib/classifier-reborn/lsi/summarizer.rb:28:in perform_lsi'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/classifier-reborn-2.1.0/lib/classifier-reborn/lsi/summarizer.rb:10:in summary' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:21:in header'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:126:in block in generate_articles' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in each'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in each_slice' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in with_index'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in each' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in map'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in generate_articles' from test.rb:21:in

'

What do you think can be the problem? Thanks so much if you can take a look.

@tra38 tra38 self-assigned this Apr 14, 2017
@tra38
Copy link
Owner

tra38 commented Apr 15, 2017

Classifier-Reborn (the Ruby gem that ZombieWriter is dependent on) needs to do some complex matrix multiplication to perform latent semantic analysis (both for generating articles using Machine Learning and coming up with titles for news articles). There are two ways by which Classifier-Reborn does this multiplication:

  1. Check if you have GNU GSL and rb-gsl (a Ruby gem that interfaces with the GSL library) installed. If you have, then use the GSL to conduct the matrix multiplication.
  2. If you don't have that software installed, then simply use a native, slow, and buggy Ruby implementation.

Since line 309 of lsi.rb can only be accessed if Classifier-Reborn has taken Option 2, this suggests that there is a problem with the Ruby implementation of the matrix multiplication.

The classifier-reborn README recommends installing GNU GSL and rb-gsl because it would "speed up LSI classification by at least 10x". As a result of this recommendation, there really hasn't been much maintenance work with the native Ruby code, and I am not good at linear algebra to personally debug the issue (nor would I want to, since GNU GSL and rb-gsl already exists and would be much more efficient than anything I could do).

So my recommendation would be to follow classifier-reborn's recommendation - install GNU GSL and rb-gsl, and then try to run your script again. Classifier-Reborn should be able to detect the presence of the GSL library. When I run the script with GSL on my computer, it works perfectly (and when I disable GSL, I get the same error you did).

Let me know if this solution works for you. If it does, I'll update the README to strongly recommend users install GNU GSL and rb-gsl before using this Ruby gem.

@masdc
Copy link
Author

masdc commented Apr 15, 2017

I tried to run the software in a newly configured Ubuntu 16.04 and with a default install of Ruby 2.4 it didn't work. Same errors as in Windows:

/home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/classifier-reborn-2.1.0/lib/classifier-reborn/lsi.rb:309:in sort': comparison of Float with NaN failed (ArgumentError) from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/classifier-reborn-2.1.0/lib/classifier-reborn/lsi.rb:309:in build_reduced_matrix'
from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/classifier-reborn-2.1.0/lib/classifier-reborn/lsi.rb:143:in build_index' from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/classifier-reborn-2.1.0/lib/classifier-reborn/lsi/summarizer.rb:28:in perform_lsi'
from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/classifier-reborn-2.1.0/lib/classifier-reborn/lsi/summarizer.rb:10:in summary' from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:21:in header'
from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:126:in block in generate_articles' from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in each'
from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in each_slice' from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in with_index'
from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in each' from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in map'
from /home/masdc/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:116:in `generate_articles'

After 1 hour of research and fails i got it.

I installed the following libraries, components and gems:

sudo apt install linuxbrew-wrapper
brew install gsl
sudo apt-get install libgsl0-dev
gem install gsl

After that i was able to run Zombie Writer.

Thanks so much for your help and guidance. GSL is a required component. I will try to do the same on the Windows machine. I read that by using Cygwin in Microsoft Windows i might be able to run GSL and hopefully Zombie Writer.

@masdc masdc closed this as completed Apr 16, 2017
tra38 added a commit that referenced this issue Apr 16, 2017
By mandating that users install GSL on their local computers,
I will prevent problems like Issue #5 from arising again.

In the future, I may want to make rb-gsl a required dependency,
but I want to make sure that it won't break in case someone
forgots to install GSL on the local machine as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants