Class: Classified::ClassifierLSI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#transform

Constructor Details

#initialize(options = {}) ⇒ ClassifierLSI

Returns a new instance of ClassifierLSI.



6
7
8
9
10
# File 'lib/classifiers/classifier_lsi.rb', line 6

def initialize options = {}
  @options = { :classes => [:positive, :negative]}.merge!(options)
  @classifier = ::Classifier::LSI.new
  #@classifier = ::Classifier::Bayes.new options[:classes]
end

Instance Attribute Details

#classifierObject

Returns the value of attribute classifier.



5
6
7
# File 'lib/classifiers/classifier_lsi.rb', line 5

def classifier
  @classifier
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/classifiers/classifier_lsi.rb', line 5

def options
  @options
end

Instance Method Details

#classificationsObject



20
21
22
# File 'lib/classifiers/classifier_lsi.rb', line 20

def classifications
  @options[:classes]
end

#classify(text) ⇒ Object



16
17
18
# File 'lib/classifiers/classifier_lsi.rb', line 16

def classify text
  @classifier.classify text
end

#train(classification, text) ⇒ Object



12
13
14
# File 'lib/classifiers/classifier_lsi.rb', line 12

def train classification, text
  @classifier.add_item(text, "train_#{classification.to_s}")
end