Class: TinyClassifier::Command::Retrain
- Defined in:
- lib/tiny-classifier/command/retrain.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(argv = []) ⇒ Retrain
constructor
A new instance of Retrain.
- #run ⇒ Object
Methods inherited from Base
#data_file_name, #data_file_path, #parse_command_line_options, run
Constructor Details
#initialize(argv = []) ⇒ Retrain
Returns a new instance of Retrain.
21 22 23 24 25 26 27 |
# File 'lib/tiny-classifier/command/retrain.rb', line 21 def initialize(argv=[]) super option_parser. += " WRONG CORRECT" *categories = (argv) @wrong_category = categories.shift @correct_category = categories.shift end |
Instance Method Details
#run ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tiny-classifier/command/retrain.rb', line 29 def run super prepare_categories raise NoEffectiveInput.new if input.empty? raise NoTrainingData.new(data_file_path) unless data_file_path.exist? classifier.untrain(@wrong_category, input) classifier.train(@correct_category, input) save true rescue StandardError => error handle_error(error) end |