Class: DidYouMean::CorrectElement
- Inherits:
-
Object
- Object
- DidYouMean::CorrectElement
- Defined in:
- lib/did_you_mean/tree_spell_checker.rb
Overview
identifies the elements close to element
Instance Method Summary collapse
- #call(names, element) ⇒ Object
-
#initialize ⇒ CorrectElement
constructor
A new instance of CorrectElement.
Constructor Details
#initialize ⇒ CorrectElement
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 |