Sha256: 2ae70c26f2a60754f66b211b643af9b6f09fa814fb2039e8e9c19a1f9a0ee3a1

Contents?: true

Size: 356 Bytes

Versions: 4

Compression:

Stored size: 356 Bytes

Contents

module Classiphier
  class Data < Hash
    def initialize
      self[:data]  = {}
      self.default = 0
    end

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
classiphier-0.1.3 lib/classiphier/data.rb
classiphier-0.1.2 lib/classiphier/data.rb
classiphier-0.1.1 lib/classiphier/data.rb
classiphier-0.1.0 lib/classiphier/data.rb