class Enums::Fuzziness

A unit class that encapsulates all in-exact search parsing and conversion from similarities to edit distances etc.

Constants

AUTO

@!visibility protected

ONE

@!visibility protected

TWO

@!visibility protected

ZERO

@!visibility protected

Attributes

fuzziness[R]

@!visibility protected

Public Class Methods

auto(low = nil, high = nil) click to toggle source

Returns a fuzziness object with maximum levenshtein distance in auto mode.

Generates an edit distance based on the length of the term.
Low and high distance arguments may be optionally provided
AUTO:[low],[high]. If not specified, the default values are 3 and 6,
equivalent to AUTO:3,6 that make for lengths:
  0..2
    Must match exactly
  3..5
    One edit allowed
  >5
    Two edits allowed
AUTO should generally be the preferred value for fuzziness.
# File lib/enums/fuzziness.rb, line 48
def self.auto(low = nil, high = nil)
  new("#{AUTO}:#{low},#{high}")
end
new(fuzziness_value) click to toggle source

@!visibility protected

# File lib/enums/fuzziness.rb, line 52
def initialize(fuzziness_value)
  @fuzziness = fuzziness_value
end
one() click to toggle source

@return [Fuzziness] returns a fuzziness object with

maximum levenshtein distance as one.
# File lib/enums/fuzziness.rb, line 26
def self.one
  new(ONE)
end
two() click to toggle source

@return [Fuzziness] returns a fuzziness object with

maximum levenshtein distance as two.
# File lib/enums/fuzziness.rb, line 32
def self.two
  new(TWO)
end
zero() click to toggle source

@return [Fuzziness] returns Fuzziness object corresponding to

exact match
# File lib/enums/fuzziness.rb, line 20
def self.zero
  new(ZERO)
end