Method: Inferx#score
- Defined in:
- lib/inferx.rb
#score(category, words) ⇒ Float
Get a score of a category according to a set of words.
26 27 28 29 30 31 |
# File 'lib/inferx.rb', line 26 def score(category, words) size = category.size.to_f return -Float::INFINITY unless size > 0 scores = category.scores(words) scores.inject(0.0) { |s, score| s + Math.log((score || 0.1) / size) } end |