Method: PEROBS::FuzzyStringMatcher#initialize

Defined in:
lib/perobs/FuzzyStringMatcher.rb

#initialize(p, case_sensitive = false, n = 4) ⇒ FuzzyStringMatcher

Create a new FuzzyStringMatcher.

Parameters:

  • p (PEROBS::Store)

    place to store the dictionary

  • case_sensitive (Boolean) (defaults to: false)

    True if case matters for matching

  • n (Integer) (defaults to: 4)

    Determines what kind of n-gramm is used to store the references in the dictionary. It also determines the minimum word length that can be used for fuzzy matches. Values between 2 and 10 are supported. The default is 4.



51
52
53
54
55
56
57
58
59
60
# File 'lib/perobs/FuzzyStringMatcher.rb', line 51

def initialize(p, case_sensitive = false, n = 4)
  super(p)
  if n < 2 || n > 10
    raise ArgumentError, 'n must be between 2 and 10'
  end
  self.case_sensitive = case_sensitive
  self.n = n

  clear unless @dict
end