class NBayes::Vocab
Attributes
log_size[RW]
tokens[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/nbayes.rb, line 18 def initialize(options = {}) @tokens = Hash.new # for smoothing, use log of vocab size, rather than vocab size @log_size = options[:log_size] end
Public Instance Methods
delete(token)
click to toggle source
# File lib/nbayes.rb, line 24 def delete(token) tokens.delete(token) end
each(&block)
click to toggle source
# File lib/nbayes.rb, line 28 def each(&block) tokens.keys.each(&block) end
seen_token(token)
click to toggle source
# File lib/nbayes.rb, line 40 def seen_token(token) tokens[token] = 1 end
size()
click to toggle source
# File lib/nbayes.rb, line 32 def size if log_size Math.log(tokens.count) else tokens.count end end