Skip to content
Merged
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
4 changes: 2 additions & 2 deletions lib/classifier/lsi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def highest_relative_content(max_chunks = 10)
return [] if needs_rebuild?

avg_density = {}
@items.each_key { |x| avg_density[x] = proximity_array_for_content(x).inject(0.0) { |i, j| i + j[1] } }
@items.each_key { |x| avg_density[x] = proximity_array_for_content(x).sum { |pair| pair[1] } }

avg_density.keys.sort_by { |x| avg_density[x] }.reverse[0..(max_chunks - 1)].map
end
Expand Down Expand Up @@ -300,7 +300,7 @@ def vote(doc, cutoff = 0.30, &)
# See classify() for argument docs
def classify_with_confidence(doc, cutoff = 0.30, &)
votes = vote(doc, cutoff, &)
votes_sum = votes.values.inject(0.0) { |sum, v| sum + v }
votes_sum = votes.values.sum
return [nil, nil] if votes_sum.zero?

ranking = votes.keys.sort_by { |x| votes[x] }
Expand Down