Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions README.markdown → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,27 @@ Classifier is a general module to allow Bayesian and other types of classificati

## Dependencies

If you install Classifier from source, you'll need to install Roman Shterenzon's fast-stemmer gem with RubyGems as follows:
The `fast-stemmer` gem is required:

gem install fast-stemmer

If you would like to speed up LSI classification by at least 10x, please install the following libraries:
GNU GSL:: http://www.gnu.org/software/gsl
rb-gsl:: https://github.com/SciRuby/rb-gsl
### Optional: GSL for Faster LSI

Notice that LSI will work without these libraries, but as soon as they are installed, Classifier will make use of them. No configuration changes are needed, we like to keep things ridiculously easy for you.
For 10x faster LSI classification, install the GNU Scientific Library and its Ruby bindings:

# macOS
brew install gsl
gem install gsl

# Ubuntu/Debian
apt-get install libgsl-dev
gem install gsl

LSI works without GSL using a pure Ruby implementation. When GSL is installed, Classifier automatically uses it with no configuration needed.

To suppress the GSL notice when not using it:

SUPPRESS_GSL_WARNING=true ruby your_script.rb

## Bayes

Expand Down
6 changes: 4 additions & 2 deletions lib/classifier/lsi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ class << self
raise LoadError if ENV['NATIVE_VECTOR'] == 'true'
raise LoadError unless Gem::Specification.find_all_by_name('gsl').any?

require 'gsl' # requires https://github.com/SciRuby/rb-gsl/
require 'gsl'
require 'classifier/extensions/vector_serialize'
Classifier::LSI.gsl_available = true
rescue LoadError
warn 'Notice: for 10x faster LSI support in the classifier gem, please install the gsl gem'
unless ENV['SUPPRESS_GSL_WARNING'] == 'true'
warn 'Notice: for 10x faster LSI, run `gem install gsl`. Set SUPPRESS_GSL_WARNING=true to hide this.'
end
Classifier::LSI.gsl_available = false
require 'classifier/extensions/vector'
end
Expand Down