Class: OmniCat::Classifiers::BayesInternals::Category

Inherits:
Base
  • Object
show all
Defined in:
lib/omnicat/classifiers/bayes_internals/category.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_hash

Constructor Details

#initialize(category_hash = {}) ⇒ Category

Returns a new instance of Category.



7
8
9
10
11
12
# File 'lib/omnicat/classifiers/bayes_internals/category.rb', line 7

def initialize(category_hash = {})
  self.doc_count = category_hash[:doc_count].to_i
  self.prior = category_hash[:prior].to_f
  self.tokens = category_hash[:tokens] || {}
  self.token_count = category_hash[:token_count].to_i
end

Instance Attribute Details

#doc_countObject

Returns the value of attribute doc_count.



5
6
7
# File 'lib/omnicat/classifiers/bayes_internals/category.rb', line 5

def doc_count
  @doc_count
end

#priorObject

Returns the value of attribute prior.



5
6
7
# File 'lib/omnicat/classifiers/bayes_internals/category.rb', line 5

def prior
  @prior
end

#token_countObject

Returns the value of attribute token_count.



5
6
7
# File 'lib/omnicat/classifiers/bayes_internals/category.rb', line 5

def token_count
  @token_count
end

#tokensObject

Returns the value of attribute tokens.



5
6
7
# File 'lib/omnicat/classifiers/bayes_internals/category.rb', line 5

def tokens
  @tokens
end