class Category
Attributes
id[R]
name[R]
weight[R]
Public Class Methods
new(args)
click to toggle source
# File lib/NaiveText/Category.rb, line 6 def initialize(args) @name = args[:name] @examples = args[:examples] @weight = args[:weight] || 1 @id = @@id_counter @@id_counter += 1 end
Public Instance Methods
p(word)
click to toggle source
# File lib/NaiveText/Category.rb, line 15 def p(word) if @examples.word_count > 0 @examples.count(word).to_f / @examples.word_count else 0 end end
to_s()
click to toggle source
# File lib/NaiveText/Category.rb, line 27 def to_s @name end
word_count()
click to toggle source
# File lib/NaiveText/Category.rb, line 23 def word_count @examples.word_count end