Method: Bundler::SimilarityDetector#similar_words

Defined in:
lib/bundler/similarity_detector.rb

#similar_words(word, limit = 3) ⇒ Object

return an array of words similar to ‘word’ from the corpus



13
14
15
16
# File 'lib/bundler/similarity_detector.rb', line 13

def similar_words(word, limit = 3)
  words_by_similarity = @corpus.map {|w| SimilarityScore.new(w, levenshtein_distance(word, w)) }
  words_by_similarity.select {|s| s.distance <= limit }.sort_by(&:distance).map(&:string)
end