Sha256: 25ed335b9a75216cc1dbfcf0a079323e72fe0d3bd368c59dd5a049ad7c8ea3d5
Contents?: true
Size: 712 Bytes
Versions: 1
Compression:
Stored size: 712 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| first_char = token[0][0] names = NamesLoader.names_by_first_letter(first_char.downcase) m = Amatch::JaroWinkler.new(token) score += names.map do |name| m.match(name) end.max end score /= @token_array.length score end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
guess_who-0.1.2 | lib/guess_who/scorer.rb |