class DidYouMean::CorrectElement

identifies the elements close to element

Public Class Methods

new() click to toggle source
# File did_you_mean/tree_spell_checker.rb, line 117
def initialize
end

Public Instance Methods

call(names, element) click to toggle source
# File 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

Private Instance Methods

normalize(leaf) click to toggle source
# File did_you_mean/tree_spell_checker.rb, line 130
def normalize(leaf)
  str = leaf.dup
  str.downcase!
  return str unless str.include? '@'
  str.tr!('@', '  ')
end