Class: Classified::Ankusa
Instance Attribute Summary collapse
-
#classifier ⇒ Object
Returns the value of attribute classifier.
Instance Method Summary collapse
- #classifications ⇒ Object
- #classify(text) ⇒ Object
-
#initialize(options = {}) ⇒ Ankusa
constructor
A new instance of Ankusa.
- #save ⇒ Object
- #train(classification, text) ⇒ Object
Methods inherited from Base
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 = {} case .delete(:storage) when :memory @storage = ::Ankusa::MemoryStorage.new when :file @storage = ::Ankusa::FileSystemStorage.new .delete(:file) else @storage = ::Ankusa::MemoryStorage.new end @classifier = ::Ankusa::NaiveBayesClassifier.new @storage end |
Instance Attribute Details
#classifier ⇒ Object
Returns the value of attribute classifier.
8 9 10 |
# File 'lib/classifiers/ankusa.rb', line 8 def classifier @classifier end |
Instance Method Details
#classifications ⇒ Object
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 |
#save ⇒ Object
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 |