class AlfonsoX::SpellChecker::Dictionary::Hunspell
Hunspell
dictionary loader
Constants
- DEFAULT_PATH
Default
hunspell dictionary path
Attributes
language[R]
All attributes are readable
path[R]
All attributes are readable
Public Class Methods
from_config(yml_config)
click to toggle source
Load a hunspell dictionary from configuration
# File lib/alfonsox/spellchecker/dictionary/hunspell.rb, line 24 def self.from_config(yml_config) new(yml_config['language'], yml_config.fetch('path') { DEFAULT_PATH }) end
new(language, path = nil)
click to toggle source
Construct a hunspell dictionary object for this package
# File lib/alfonsox/spellchecker/dictionary/hunspell.rb, line 17 def initialize(language, path = nil) @language = language @path = path || DEFAULT_PATH initialize_spellchecker(path) end
Public Instance Methods
initialize_spellchecker(path)
click to toggle source
Initialize spellchecker attribute
# File lib/alfonsox/spellchecker/dictionary/hunspell.rb, line 34 def initialize_spellchecker(path) dictionary_finder = DictionaryFinder.new(@language, path) raise "'#{@language}' language Hunspell dictionary not found" unless dictionary_finder.find @spellchecker = ::Hunspell.new(dictionary_finder.aff_file_path, dictionary_finder.dic_file_path) end
word_present?(word)
click to toggle source
Inform if a word is present in this dictionary.
# File lib/alfonsox/spellchecker/dictionary/hunspell.rb, line 29 def word_present?(word) @spellchecker.spellcheck(word) end