class TinyClassifier::Command::Untrain

Public Class Methods

new(argv=[]) click to toggle source
Calls superclass method TinyClassifier::Command::Base::new
# File lib/tiny-classifier/command/untrain.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/untrain.rb, line 28
def run
  super
  @category = prepare_category(@category)
  log("untraining as: #{@category}")
  raise NoEffectiveInput.new if input.empty?
  raise NoTrainingData.new(data_file_path) unless data_file_path.exist?

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