Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/bayes/bishop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
Expand All @@ -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 }
Expand Down Expand Up @@ -356,4 +358,4 @@ def self.chi2p( chi, df )
[1.0, sum].min
end

end
end