Class: Classiphier::Data

Inherits:
Hash
  • Object
show all
Defined in:
lib/classiphier/data.rb

Instance Method Summary collapse

Constructor Details

#initializeData

Returns a new instance of Data.



3
4
5
6
# File 'lib/classiphier/data.rb', line 3

def initialize
  self[:data]  = {}
  self.default = 0
end

Instance Method Details

#perform!Object



17
18
19
# File 'lib/classiphier/data.rb', line 17

def perform!
  self[:count] += 1
end

#train(sentence) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/classiphier/data.rb', line 8

def train(sentence)
  perform!
  sentence.words.each do |word|
    self[:data][word] ||= 0
    self[:data][word] += 1
    self[:words] += 1
  end
end