Module: SpellKit

Defined in:
lib/spellkit.rb,
lib/spellkit/version.rb

Defined Under Namespace

Classes: Checker, Configuration, DownloadError, Error, FileNotFoundError, InvalidArgumentError, NotLoadedError

Constant Summary collapse

DEFAULT_DICTIONARY_URL =

Default dictionary: SymSpell English 80k frequency dictionary

"https://raw.githubusercontent.com/wolfgarbe/SymSpell/master/SymSpell.FrequencyDictionary/en-80k.txt"
VERSION =
"0.2.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.defaultObject



63
64
65
66
67
68
69
# File 'lib/spellkit.rb', line 63

def default
  @default ||= begin
    checker = Checker.new
    checker.load!(dictionary: DEFAULT_DICTIONARY_URL)
    checker
  end
end

Class Method Details

.configure {|config| ... } ⇒ Object

Yields:

  • (config)


55
56
57
58
59
60
61
# File 'lib/spellkit.rb', line 55

def configure
  config = Configuration.new
  yield(config)
  @default = Checker.new
  @default.load!(**config.to_h)
  @default
end

.correct(word) ⇒ Object



86
87
88
# File 'lib/spellkit.rb', line 86

def correct(word)
  default.correct(word)
end

.correct?(word) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/spellkit.rb', line 82

def correct?(word)
  default.correct?(word)
end

.correct_tokens(tokens) ⇒ Object



90
91
92
# File 'lib/spellkit.rb', line 90

def correct_tokens(tokens)
  default.correct_tokens(tokens)
end

.healthcheckObject



98
99
100
# File 'lib/spellkit.rb', line 98

def healthcheck
  default.healthcheck
end

.load!(**options) ⇒ Object

Delegation methods



72
73
74
75
76
# File 'lib/spellkit.rb', line 72

def load!(**options)
  @default = Checker.new
  @default.load!(**options)
  @default
end

.statsObject



94
95
96
# File 'lib/spellkit.rb', line 94

def stats
  default.stats
end

.suggestions(word, max = 5) ⇒ Object



78
79
80
# File 'lib/spellkit.rb', line 78

def suggestions(word, max = 5)
  default.suggestions(word, max)
end