class AlfonsoX::SpellChecker::Dictionary::WordList

Custom dictionary loader composed by a word list

Attributes

words[R]

Public Class Methods

from_config(yml_config) click to toggle source

Load from Yml

# File lib/alfonsox/spellchecker/dictionary/word_list.rb, line 20
def self.from_config(yml_config)
  new(yml_config.fetch('word_list') { [] })
end
new(word_list) click to toggle source

Initialize a AlfonsoX::SpellChecker::Dictionary::WordList @param [Array<String>] word_list Words that are included in this dictionary

# File lib/alfonsox/spellchecker/dictionary/word_list.rb, line 15
def initialize(word_list)
  @words = word_list.map(&:downcase)
end

Public Instance Methods

word_present?(word) click to toggle source

Inform if a word is present in this dictionary.

# File lib/alfonsox/spellchecker/dictionary/word_list.rb, line 25
def word_present?(word)
  @words.include?(word.downcase)
end