Sha256: b9ae22ebb410a4a190fa6136a785b9e7ab62020af1605aa6ff02e45070efc440

Contents?: true

Size: 532 Bytes

Versions: 5

Compression:

Stored size: 532 Bytes

Contents

module SpellCheck
  class Filter
    TYPO_PATTERN_LIST = {}

    Dir.glob(File.expand_path('../patterns/**/*.yml', __FILE__)) do |f|
      TYPO_PATTERN_LIST.merge!(YAML.load(File.read(f)))
    end

    # @param [String] string to be checked.
    # @return [Hash] check result.
    def self.spellcheck(word)
      expected = TYPO_PATTERN_LIST[word.downcase]

      if expected
        { correct: false, pattern: word, expected: expected }
      else
        { correct: true, pattern: word, expected: '' }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spellcheck-0.3.4 lib/spellcheck/filter.rb
spellcheck-0.3.3 lib/spellcheck/filter.rb
spellcheck-0.3.2 lib/spellcheck/filter.rb
spellcheck-0.3.1 lib/spellcheck/filter.rb
spellcheck-0.3.0 lib/spellcheck/filter.rb