Class: BowTfidf::Classifier
- Inherits:
-
Object
- Object
- BowTfidf::Classifier
- Defined in:
- lib/bow_tfidf/classifier.rb
Instance Attribute Summary collapse
-
#bow ⇒ Object
readonly
Returns the value of attribute bow.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
- #call(tokens) ⇒ Object
-
#initialize(bow) ⇒ Classifier
constructor
A new instance of Classifier.
Constructor Details
#initialize(bow) ⇒ Classifier
Returns a new instance of Classifier.
5 6 7 8 9 |
# File 'lib/bow_tfidf/classifier.rb', line 5 def initialize(bow) raise(ArgumentError, 'BowTfidf::BagOfWords instance expected') unless bow.is_a?(BowTfidf::BagOfWords) @bow = bow end |
Instance Attribute Details
#bow ⇒ Object (readonly)
Returns the value of attribute bow.
3 4 5 |
# File 'lib/bow_tfidf/classifier.rb', line 3 def bow @bow end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
3 4 5 |
# File 'lib/bow_tfidf/classifier.rb', line 3 def score @score end |
Instance Method Details
#call(tokens) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bow_tfidf/classifier.rb', line 11 def call(tokens) raise(ArgumentError, 'Array of strings expected') unless tokens.is_a?(Array) @score = {} tokens.each do |word| process_word(word) end result end |