Class: TinyClassifier::Classifier

Inherits:
Base
  • Object
show all
Defined in:
lib/tiny-classifier/classifier.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#tokenizer

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#classifier, #initialize, #parse_command_line_options

Constructor Details

This class inherits a constructor from TinyClassifier::Base

Instance Attribute Details

#classifier=(value) ⇒ Object (writeonly)

Sets the attribute classifier

Parameters:

  • value

    the value to set the attribute classifier to.



29
30
31
# File 'lib/tiny-classifier/classifier.rb', line 29

def classifier=(value)
  @classifier = value
end

Class Method Details

.run(argv = nil) ⇒ Object



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

def run(argv=nil)
  argv ||= ARGV.dup
  classifier = new
  classifier.parse_command_line_options(argv)
  classifier.run
end

Instance Method Details

#runObject



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

def run
  if input.empty?
    STDERR.puts("Error: No effective input.")
    false
  else
    label = classifier.classify(input)
    puts label.downcase
    true
  end
end