Class: Bishop::BayesData
- Inherits:
-
Object
- Object
- Bishop::BayesData
- Defined in:
- lib/bishop.rb
Overview
Ruby’s YAML persists Hashes using special processing rather than by dumping it’s instance variables, hence no instance variables in a Hash subclass get dumped either <sigh>
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
Returns the value of attribute name.
-
#token_count ⇒ Object
Returns the value of attribute token_count.
-
#train_count ⇒ Object
Returns the value of attribute train_count.
-
#training ⇒ Object
readonly
Returns the value of attribute training.
Instance Method Summary collapse
-
#initialize(name = '', pool = nil) ⇒ BayesData
constructor
A new instance of BayesData.
- #to_s ⇒ Object
- #trained_on?(item) ⇒ Boolean
Constructor Details
#initialize(name = '', pool = nil) ⇒ BayesData
Returns a new instance of BayesData.
24 25 26 27 28 29 30 31 |
# File 'lib/bishop.rb', line 24 def initialize( name = '', pool = nil ) @name = name @training = [] @pool = pool @data = Hash.new( 0.0 ) self.token_count = 0 self.train_count = 0 end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
22 23 24 |
# File 'lib/bishop.rb', line 22 def data @data end |
#name ⇒ Object
Returns the value of attribute name.
21 22 23 |
# File 'lib/bishop.rb', line 21 def name @name end |
#token_count ⇒ Object
Returns the value of attribute token_count.
21 22 23 |
# File 'lib/bishop.rb', line 21 def token_count @token_count end |
#train_count ⇒ Object
Returns the value of attribute train_count.
21 22 23 |
# File 'lib/bishop.rb', line 21 def train_count @train_count end |
#training ⇒ Object (readonly)
Returns the value of attribute training.
22 23 24 |
# File 'lib/bishop.rb', line 22 def training @training end |
Instance Method Details
#to_s ⇒ Object
37 38 39 |
# File 'lib/bishop.rb', line 37 def to_s "<BayesDict: #{self.name || noname}, #{self.token_count} tokens>" end |
#trained_on?(item) ⇒ Boolean
33 34 35 |
# File 'lib/bishop.rb', line 33 def trained_on?( item ) self.training.include? item end |