Module: Spellchecker::Dictionaries::NgramList
- Defined in:
- lib/spellchecker/dictionaries/ngram_list.rb
Constant Summary collapse
- MUTEX =
Mutex.new
- PATH =
Dictionaries.path.join('ngrams.csv')
Class Method Summary collapse
Class Method Details
.all ⇒ Hash<Array<String>, String>
12 13 14 15 16 |
# File 'lib/spellchecker/dictionaries/ngram_list.rb', line 12 def all @all || MUTEX.synchronize do @all ||= CSV.parse(PATH.read).to_h.transform_keys(&:split) end end |
.include?(list) ⇒ Boolean
20 21 22 |
# File 'lib/spellchecker/dictionaries/ngram_list.rb', line 20 def include?(list) !match(list).nil? end |
.match(list) ⇒ String
26 27 28 |
# File 'lib/spellchecker/dictionaries/ngram_list.rb', line 26 def match(list) all[list] end |