Class: Classifier

Inherits:
TinyClassifierBase show all
Defined in:
lib/tiny-classifier/classifier.rb

Constant Summary

Constants inherited from TinyClassifierBase

TinyClassifierBase::TOKENIZERS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TinyClassifierBase

#initialize, #parse_command_line_options

Constructor Details

This class inherits a constructor from TinyClassifierBase

Class Method Details

.run(argv = nil) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/tiny-classifier/classifier.rb', line 20

def run(argv=nil)
  argv ||= ARGV.dup
  classifier = new
  classifier.parse_command_line_options(argv)
  input = $stdin.readlines.join("\n")
  classifier.run(input: input)
end

Instance Method Details

#run(params) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tiny-classifier/classifier.rb', line 29

def run(params)
  @label = params[:label]
  @input = params[:input]
  prepare_input
  if @input.empty?
    exit(1)
  else
    label = classifier.classify(@input)
    puts label.downcase
    exit(0)
  end
end