Skip to content

Commit

Permalink
Monkeypatch to support both ruby 1.8 and 1.9 (key vs index method) on…
Browse files Browse the repository at this point in the history
… naives bayes implementation
  • Loading branch information
SergioFierens committed Feb 6, 2012
1 parent 8d465e9 commit 6259ee3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ai4r/classifiers/naive_bayes.rb
Expand Up @@ -54,6 +54,7 @@ module Classifiers
# build data
# b.eval(["Red", "SUV", "Domestic"])
#

class NaiveBayes < Classifier

parameters_info :m => "Default value is set to 0. It may be set to a value greater than " +
Expand Down Expand Up @@ -257,3 +258,8 @@ def [](index)
end
end
end

# Monkeypatch to support both ruby 1.8 and 1.9 (key vs index method)
class Hash
alias_method(:key, :index) unless method_defined?(:key)
end

0 comments on commit 6259ee3

Please sign in to comment.