def train(category, text)
      word_hash = Hasher.word_hash(text, @enable_stemmer,
                                   tokenizer: @tokenizer, token_filters: @token_filters)
      return if word_hash.empty?

      category = CategoryNamer.prepare_name(category)

      # Add the category dynamically or raise an error
      unless category_keys.include?(category)
        if @auto_categorize
          add_category(category)
        else
          raise CategoryNotFoundError, "Cannot train; category #{category} does not exist"
        end
      end

      word_hash.each do |word, count|
        @backend.update_category_word_frequency(category, word, count)
        @backend.update_category_word_count(category, count)
        @backend.update_total_words(count)
      end
      @backend.update_total_trainings(1)
      @backend.update_category_training_count(category, 1)
    end
def train(category, text)
      word_hash = Hasher.word_hash(text, @enable_stemmer,
                                   tokenizer: @tokenizer, token_filters: @token_filters)
      return if word_hash.empty?

      category = CategoryNamer.prepare_name(category)

      # Add the category dynamically or raise an error
      unless category_keys.include?(category)
        if @auto_categorize
          add_category(category)
        else
          raise CategoryNotFoundError, "Cannot train; category #{category} does not exist"
        end
      end

      word_hash.each do |word, count|
        @backend.update_category_word_frequency(category, word, count)
        @backend.update_category_word_count(category, count)
        @backend.update_total_words(count)
      end
      @backend.update_total_trainings(1)
      @backend.update_category_training_count(category, 1)
    end
The class can be created with one or more categories, each of which will be
 initialized and given a training method. E.g.,
      b = ClassifierReborn::Bayes.new 'Interesting', 'Uninteresting', 'Spam'

 Options available are:
   language:         'en'                    Used to select language specific stop words
   auto_categorize:  false                   When true, enables ability to dynamically declare a category; the default is true if no initial categories are provided
   enable_threshold: false                   When true, enables a threshold requirement for classifition
   threshold:        0.0                     Default threshold, only used when enabled
   enable_stemmer:   true                    When false, disables word stemming
   stopwords:        nil                     Accepts path to a text file or an array of words, when supplied, overwrites the default stopwords; assign empty string or array to disable stopwords
   backend:          BayesMemoryBackend.new  Alternatively, BayesRedisBackend.new for persistent storage
 Provides a general training method for all categories specified in Bayes#new
 For example:
     b = ClassifierReborn::Bayes.new 'This', 'That', 'the_other'
     b.train :this, "This text"
     b.train "that", "That text"
     b.train "The other", "The other text"