Sha256: 0952907904326eac291136a9429e64676cd0614785d0dd279745b8161c91d17c

Contents?: true

Size: 566 Bytes

Versions: 1

Compression:

Stored size: 566 Bytes

Contents

require 'fuzzy_match/score/pure_ruby'
require 'fuzzy_match/score/amatch'

class FuzzyMatch
  class Score
    include Comparable
    
    attr_reader :str1
    attr_reader :str2

    def initialize(str1, str2)
      @str1 = str1.downcase
      @str2 = str2.downcase
    end

    def <=>(other)
      a = dices_coefficient_similar
      b = other.dices_coefficient_similar
      if a.nan? or b.nan? or (by_dices_coefficient = (a <=> b)) == 0
        levenshtein_similar <=> other.levenshtein_similar
      else
        by_dices_coefficient
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fuzzy_match-1.5.0 lib/fuzzy_match/score.rb