diff --git a/lib/bayes/bishop.rb b/lib/bayes/bishop.rb index 320b5ad..204d9f8 100755 --- a/lib/bayes/bishop.rb +++ b/lib/bayes/bishop.rb @@ -154,8 +154,10 @@ def save( file = 'bayesdata.yml' ) # Define the YAML representation of the state of the classifier (possibly this # should just be an override of the to_yaml method generated by the YAML module). - def export - { :pools => self.pools, :train_count => self.train_count, :stop_words => self.stop_words }.to_yaml + def export( dumper = YAML ) + data = { :pools => self.pools, :train_count => self.train_count, :stop_words => self.stop_words } + + dumper.dump(data) end def load( file = 'bayesdata.yml' ) @@ -166,8 +168,8 @@ def load( file = 'bayesdata.yml' ) end end - def load_data( source ) - data = YAML.load( source ) + def load_data( source, loader = YAML ) + data = loader.load( source ) @pools = data[:pools] @pools.each { |pool_name,pool| pool.data.default = 0.0 } @@ -356,4 +358,4 @@ def self.chi2p( chi, df ) [1.0, sum].min end -end \ No newline at end of file +end