Module: Spellchecker::Dictionaries::TyposList
- Defined in:
- lib/spellchecker/dictionaries/typos_list.rb
Constant Summary collapse
- MUTEX =
Mutex.new
- PATH =
Dictionaries.path.join('typos.csv')
Class Method Summary collapse
- .all ⇒ Hash<String, String>
- .include?(word) ⇒ Boolean
- .match(word) ⇒ String?
- .match_token(token) ⇒ String?
Class Method Details
.all ⇒ Hash<String, String>
12 13 14 15 16 |
# File 'lib/spellchecker/dictionaries/typos_list.rb', line 12 def all @all || MUTEX.synchronize do @all ||= CSV.parse(PATH.read).to_h end end |
.include?(word) ⇒ Boolean
20 21 22 |
# File 'lib/spellchecker/dictionaries/typos_list.rb', line 20 def include?(word) !match(word).nil? end |
.match(word) ⇒ String?
26 27 28 |
# File 'lib/spellchecker/dictionaries/typos_list.rb', line 26 def match(word) all[Utils.replace_quote(word.to_s.downcase)] end |
.match_token(token) ⇒ String?
32 33 34 |
# File 'lib/spellchecker/dictionaries/typos_list.rb', line 32 def match_token(token) all[token.normalized] end |