Class: Enums::Fuzziness
- Inherits:
-
Object
- Object
- Enums::Fuzziness
- Defined in:
- lib/enums/fuzziness.rb
Overview
A unit class that encapsulates all in-exact search parsing and conversion from similarities to edit distances etc.
Class Method Summary collapse
-
.auto(low = nil, high = nil) ⇒ Object
Returns a fuzziness object with maximum levenshtein distance in auto mode.
-
.one ⇒ Fuzziness
Returns a fuzziness object with maximum levenshtein distance as one.
-
.two ⇒ Fuzziness
Returns a fuzziness object with maximum levenshtein distance as two.
-
.zero ⇒ Fuzziness
Returns Fuzziness object corresponding to exact match.
Class Method Details
.auto(low = nil, high = nil) ⇒ Object
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.
48 49 50 |
# File 'lib/enums/fuzziness.rb', line 48 def self.auto(low = nil, high = nil) new("#{AUTO}:#{low},#{high}") end |
.one ⇒ Fuzziness
Returns a fuzziness object with maximum levenshtein distance as one.
26 27 28 |
# File 'lib/enums/fuzziness.rb', line 26 def self.one new(ONE) end |
.two ⇒ Fuzziness
Returns a fuzziness object with maximum levenshtein distance as two.
32 33 34 |
# File 'lib/enums/fuzziness.rb', line 32 def self.two new(TWO) end |
.zero ⇒ Fuzziness
Returns Fuzziness object corresponding to exact match
20 21 22 |
# File 'lib/enums/fuzziness.rb', line 20 def self.zero new(ZERO) end |