Sha256: be902df63163e98ca2cd2e18a044bf910d71549b69244139215e3b6bcf4f5a78
Contents?: true
Size: 620 Bytes
Versions: 2
Compression:
Stored size: 620 Bytes
Contents
module GuessWho class Scorer def self.score!(token_arrays, &block) scores = [] token_arrays.each do |token_array| scorer = Scorer.new(token_array) score = scorer.score! yield score, token_array end scores end def initialize(token_array) @token_array = token_array end def score! score = 0 @token_array.each do |token| m = Amatch::JaroWinkler.new(token) score += NamesLoader.names.map do |name| m.match(name) end.max end score /= @token_array.length score end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
guess_who-0.1.1 | lib/guess_who/scorer.rb |
guess_who-0.1.0 | lib/guess_who/scorer.rb |