Sha256: 630b06c5c723dad9b290353918e3db29609b2a736c6f6dfcf09c1a3ec9d0470e
Contents?: true
Size: 920 Bytes
Versions: 1
Compression:
Stored size: 920 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 from a file class WordListFile attr_reader :words # Initialize a AlfonsoX::SpellChecker::Dictionary::WordListFile from a file path. # Note the words must be in different lines. # @param [String] word_list_file_path Word list file path. def initialize(word_list_file_path) word_list = ::File.readlines(word_list_file_path).map(&:chomp) @words = word_list.map(&:downcase) end # Load from Yml def self.from_config(yml_config) new(yml_config['path']) end # Inform if a word is present in this dictionary. def word_present?(word) @words.include?(word.downcase) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alfonsox-0.2.8 | lib/alfonsox/spellchecker/dictionary/word_list_file.rb |