Sha256: 01099ac2fd40d3e9eff23ffdc7445874c8223f2f7afbf9e72696d3ee6076aa40

Contents?: true

Size: 673 Bytes

Versions: 5

Compression:

Stored size: 673 Bytes

Contents

# frozen_string_literal: true

require 'nokogiri'

# Alfonso X module
module AlfonsoX
  module SpellChecker
    module Dictionary
      # Custom dictionary loader composed by a word list
      class WordList
        # Initialize a AlfonsoX::SpellChecker::Dictionary::WordList
        # @param [Array<String>] word_list Words that are included in this dictionary
        def initialize(word_list)
          @words = word_list.map(&:downcase)
        end

        def self.from_config(yml_config)
          new(yml_config.fetch('word_list') { [] })
        end

        def word_present?(word)
          @words.include?(word.downcase)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alfonsox-0.2.7 lib/alfonsox/spellchecker/dictionary/word_list.rb
alfonsox-0.2.6 lib/alfonsox/spellchecker/dictionary/word_list.rb
alfonsox-0.2.5 lib/alfonsox/spellchecker/dictionary/word_list.rb
alfonsox-0.1.1 lib/alfonsox/spellchecker/dictionary/word_list.rb
alfonsox-0.1.0 lib/alfonsox/spellchecker/dictionary/word_list.rb