Class: DidYouMean::CorrectElement

Inherits:
Object
  • Object
show all
Defined in:
lib/did_you_mean/tree_spell_checker.rb

Overview

identifies the elements close to element

Instance Method Summary collapse

Constructor Details

#initializeCorrectElement

Returns a new instance of CorrectElement.



117
118
# File 'lib/did_you_mean/tree_spell_checker.rb', line 117

def initialize
end

Instance Method Details

#call(names, element) ⇒ Object



120
121
122
123
124
125
126
# File 'lib/did_you_mean/tree_spell_checker.rb', line 120

def call(names, element)
  return names if names.size == 1
  str = normalize element
  return [str] if names.include? str
  checker = ::DidYouMean::SpellChecker.new(dictionary: names)
  checker.correct(str)
end