Class: Classified::ClassifierLSI
- Defined in:
- lib/classifiers/classifier_lsi.rb
Instance Attribute Summary collapse
-
#classifier ⇒ Object
Returns the value of attribute classifier.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #classifications ⇒ Object
- #classify(text) ⇒ Object
-
#initialize(options = {}) ⇒ ClassifierLSI
constructor
A new instance of ClassifierLSI.
- #train(classification, text) ⇒ Object
Methods inherited from Base
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 = { :classes => [:positive, :negative]}.merge!() @classifier = ::Classifier::LSI.new #@classifier = ::Classifier::Bayes.new options[:classes] end |
Instance Attribute Details
#classifier ⇒ Object
Returns the value of attribute classifier.
5 6 7 |
# File 'lib/classifiers/classifier_lsi.rb', line 5 def classifier @classifier end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/classifiers/classifier_lsi.rb', line 5 def @options end |
Instance Method Details
#classifications ⇒ Object
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 |