english_spellchecker 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/english_spellchecker.rb +12 -4
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 056ba76eec4fef9a43ee6f6f11a19ae1c226a402a085da7a6671dfb2ccbe1dc6
|
4
|
+
data.tar.gz: 779525c9fc9c98e5246f750321e73eba164fc053064128ee5b8e969433a375b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84dad9b1cb4eb8ee8203fed86d578cb221d1cbd3399fb26bd1a69d46cc86688430b219a3b8540a3846c8eb9eef731958ccecb7cca15eb2fac0071f17d1fa04e7
|
7
|
+
data.tar.gz: a86576181da3d4e6b475618fe18a4b8c7adbb834c7fc7388b13906105b7365434f930e551c8b2cda41023b65f4bd78b13591b3e84b9ecefd18c5d40a8e06dd8e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/english_spellchecker.rb
CHANGED
@@ -11,9 +11,14 @@ class EnglishSpellcheck
|
|
11
11
|
|
12
12
|
@words = Words2DotDat.words
|
13
13
|
|
14
|
-
def initialize()
|
14
|
+
def initialize(debug: false)
|
15
|
+
|
16
|
+
@debug = debug
|
15
17
|
@words = Words2DotDat.words
|
16
|
-
@spelling =
|
18
|
+
@spelling = ('a'..'z').map do |c|
|
19
|
+
DidYouMean::SpellChecker.new(dictionary: @words.select {|x| x[0] == c})
|
20
|
+
end
|
21
|
+
|
17
22
|
end
|
18
23
|
|
19
24
|
def self.spell(raww, verbose: true)
|
@@ -21,7 +26,8 @@ class EnglishSpellcheck
|
|
21
26
|
w = raww.downcase
|
22
27
|
|
23
28
|
return raww if @words.include? w
|
24
|
-
|
29
|
+
list = @words.select {|x| x[0] == w[0]}
|
30
|
+
r = DidYouMean::SpellChecker.new(dictionary: list).correct(w)
|
25
31
|
|
26
32
|
if r.any? then
|
27
33
|
|
@@ -60,7 +66,9 @@ class EnglishSpellcheck
|
|
60
66
|
w = raww.downcase
|
61
67
|
|
62
68
|
return raww if @words.include? w
|
63
|
-
|
69
|
+
c = w[0].ord - 97
|
70
|
+
puts 'c: ' + c.inspect if @debug
|
71
|
+
r = @spelling[c].correct w
|
64
72
|
|
65
73
|
if r.any? then
|
66
74
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: english_spellchecker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
i/2txSflqYUUrcpt7Nw/jBhIhPD17gtkt93TyMkMATK8LOOiRBzUeSoLmcUZV/cd
|
37
37
|
Os7I/4C4AaEaqtRAvendPVG41n9/F/5Hp2c=
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date: 2022-11-
|
39
|
+
date: 2022-11-04 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: words2dotdat
|
metadata.gz.sig
CHANGED
Binary file
|