Class: Classified::Ankusa

Inherits:
Base
  • Object
show all
Defined in:
lib/classifiers/ankusa.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#transform

Constructor Details

#initialize(options = {}) ⇒ Ankusa

Returns a new instance of Ankusa.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/classifiers/ankusa.rb', line 9

def initialize options = {}
  case options.delete(:storage)
  when :memory
    @storage = ::Ankusa::MemoryStorage.new
  when :file
    @storage = ::Ankusa::FileSystemStorage.new options.delete(:file)
  else
    @storage = ::Ankusa::MemoryStorage.new
  end
  @classifier = ::Ankusa::NaiveBayesClassifier.new @storage
end

Instance Attribute Details

#classifierObject

Returns the value of attribute classifier.



8
9
10
# File 'lib/classifiers/ankusa.rb', line 8

def classifier
  @classifier
end

Instance Method Details

#classificationsObject



29
30
31
# File 'lib/classifiers/ankusa.rb', line 29

def classifications
  @classifier.classnames
end

#classify(text) ⇒ Object



25
26
27
# File 'lib/classifiers/ankusa.rb', line 25

def classify text
  @classifier.classify text
end

#saveObject



33
34
35
36
# File 'lib/classifiers/ankusa.rb', line 33

def save
  # TODO: confirm this is a support method for the classifier
  @storage.save
end

#train(classification, text) ⇒ Object



21
22
23
# File 'lib/classifiers/ankusa.rb', line 21

def train classification, text
  @classifier.train classification, text
end