def classifications(text)
score = Hash.new
training_count = @category_counts.values.inject { |x,y| x+y }.to_f
@categories.each do |category, category_words|
score[category.to_s] = 0
total = category_words.values.inject(0) {|sum, element| sum+element}
text.word_hash.each do |word, count|
s = category_words.has_key?(word) ? category_words[word] : 0.1
score[category.to_s] += Math.log(s/total.to_f)
end
s = @category_counts.has_key?(category) ? @category_counts[category] : 0.1
score[category.to_s] += Math.log(s / training_count)
end
return score
end