class TinyClassifier::Command::Train

Public Class Methods

new(argv=[]) click to toggle source
Calls superclass method TinyClassifier::Command::Base::new
# File lib/tiny-classifier/command/train.rb, line 21
def initialize(argv=[])
  super
  option_parser.banner += " CATEGORY"
  *categories = parse_command_line_options(argv)
  @category = categories.first
end

Public Instance Methods

run() click to toggle source
Calls superclass method TinyClassifier::Command::Base::run
# File lib/tiny-classifier/command/train.rb, line 28
def run
  super
  @category = prepare_category(@category)
  log("training as: #{@category}")
  raise NoEffectiveInput.new if input.empty?

  classifier.train(@category, input)
  save
  true
rescue StandardError => error
  handle_error(error)
end