english_spellchecker 0.1.0 → 0.2.0
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data/lib/english_spellchecker.rb +69 -8
- data.tar.gz.sig +0 -0
- metadata +31 -27
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f850069ac6477d9ce156785bf6f4db9893e91f40f637959b90a23bf87285ba78
|
4
|
+
data.tar.gz: 640f4043b0fb8726c428b57b2e69ccdc5c5bb427055310804fc96b3eddd9ded6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7e1280603394b0812ecd41edc6fed45374b0d934803f4be7b3bcb6b933dd78b246483195a4d1775f1cc2544394a824b920c780541c401fcbe0adde499446324
|
7
|
+
data.tar.gz: 215e665255455f2978328bcfdcf9676a6c1d023a7714142f8a6008e1d9ed9f66fd176d8876da11c113de54fb43a2c026aaece8458d3a22419782e36ee6b9647a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/english_spellchecker.rb
CHANGED
@@ -8,25 +8,86 @@ require 'did_you_mean'
|
|
8
8
|
|
9
9
|
|
10
10
|
class EnglishSpellcheck
|
11
|
+
|
12
|
+
@words = WordsDotDat.words
|
11
13
|
|
12
14
|
def initialize()
|
13
|
-
@
|
15
|
+
@words = WordsDotDat.words
|
16
|
+
@spelling = DidYouMean::SpellChecker.new(dictionary: @words)
|
14
17
|
end
|
15
18
|
|
16
|
-
def self.spell(
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
def self.spell(raww, verbose: true)
|
20
|
+
|
21
|
+
w = raww.downcase
|
22
|
+
|
23
|
+
return raww if @words.include? w
|
24
|
+
r = DidYouMean::SpellChecker.new(dictionary: @words).correct(w)
|
25
|
+
|
26
|
+
if r.any? then
|
27
|
+
|
28
|
+
found = r.first
|
29
|
+
puts 'found: ' + found.inspect if verbose
|
30
|
+
|
31
|
+
# return the word found along with the ending of the keyword which
|
32
|
+
# wasn't found.
|
33
|
+
#
|
34
|
+
if raww.length > found.length then
|
35
|
+
if found == w[0..found.length-1] then
|
36
|
+
return [found, raww[found.length..-1]]
|
37
|
+
else
|
38
|
+
return found
|
39
|
+
end
|
40
|
+
else
|
41
|
+
if w == found[0..raww.length-1] then
|
42
|
+
return [raww, found[raww.length..-1]]
|
43
|
+
else
|
44
|
+
return found
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
else
|
49
|
+
nil
|
50
|
+
end
|
20
51
|
|
21
52
|
end
|
22
53
|
|
23
54
|
def inspect()
|
24
|
-
"
|
55
|
+
"#<EnglishSpellcheck:#{self.object_id} @spelling=DidYouMean::SpellChecker>"
|
25
56
|
end
|
26
57
|
|
27
|
-
def spell(
|
58
|
+
def spell(raww, verbose: true)
|
59
|
+
|
60
|
+
w = raww.downcase
|
61
|
+
|
62
|
+
return raww if @words.include? w
|
28
63
|
r = @spelling.correct w
|
29
|
-
|
64
|
+
|
65
|
+
if r.any? then
|
66
|
+
|
67
|
+
found = r.first
|
68
|
+
puts 'found: ' + found.inspect if verbose
|
69
|
+
|
70
|
+
# return the word found along with the ending of the keyword which
|
71
|
+
# wasn't found.
|
72
|
+
#
|
73
|
+
if raww.length > found.length then
|
74
|
+
if found == w[0..found.length-1] then
|
75
|
+
return [found, raww[found.length..-1]]
|
76
|
+
else
|
77
|
+
return found
|
78
|
+
end
|
79
|
+
else
|
80
|
+
if w == found[0..raww.length-1] then
|
81
|
+
return [raww, found[raww.length..-1]]
|
82
|
+
else
|
83
|
+
return found
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
else
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
|
30
91
|
end
|
31
92
|
|
32
93
|
alias spelling spell
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,28 +10,33 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIEljCCAv6gAwIBAgIBATANBgkqhkiG9w0BAQsFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
-
|
15
|
+
8ixkARkWAmV1MB4XDTIyMTAzMDE5MjkwNloXDTIzMTAzMDE5MjkwNlowSDESMBAG
|
16
16
|
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
-
EjAQBgoJkiaJk/
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoC
|
18
|
+
ggGBAIpqargIeFT5uBG37Ger1rHanRrkmn9wipLF4FqFL9822NsRF6sTE2NNXbWH
|
19
|
+
0U2xbwfEE0qB2BqgGi+g3GTaBC63LWK6CfkdlkNcrKmaCLKrNDURQEMBmUEbcnOY
|
20
|
+
9AQYI+w2OD4MTFvARAlreTxjv8EH61w1g9ksU3JqIvZzgIklI3JEOK7UaVkJS84u
|
21
|
+
GiacB7uaY4ro9D1wqiV9O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0auhLsW
|
36
|
+
i/2txSflqYUUrcpt7Nw/jBhIhPD17gtkt93TyMkMATK8LOOiRBzUeSoLmcUZV/cd
|
37
|
+
Os7I/4C4AaEaqtRAvendPVG41n9/F/5Hp2c=
|
33
38
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
39
|
+
date: 2022-10-30 00:00:00.000000000 Z
|
35
40
|
dependencies:
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: wordsdotdat
|
@@ -39,22 +44,22 @@ dependencies:
|
|
39
44
|
requirements:
|
40
45
|
- - "~>"
|
41
46
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0.
|
47
|
+
version: '0.2'
|
43
48
|
- - ">="
|
44
49
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
50
|
+
version: 0.2.0
|
46
51
|
type: :runtime
|
47
52
|
prerelease: false
|
48
53
|
version_requirements: !ruby/object:Gem::Requirement
|
49
54
|
requirements:
|
50
55
|
- - "~>"
|
51
56
|
- !ruby/object:Gem::Version
|
52
|
-
version: '0.
|
57
|
+
version: '0.2'
|
53
58
|
- - ">="
|
54
59
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
60
|
+
version: 0.2.0
|
56
61
|
description:
|
57
|
-
email:
|
62
|
+
email: digital.robertson@gmail.com
|
58
63
|
executables: []
|
59
64
|
extensions: []
|
60
65
|
extra_rdoc_files: []
|
@@ -79,8 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
84
|
- !ruby/object:Gem::Version
|
80
85
|
version: '0'
|
81
86
|
requirements: []
|
82
|
-
|
83
|
-
rubygems_version: 2.6.13
|
87
|
+
rubygems_version: 3.3.7
|
84
88
|
signing_key:
|
85
89
|
specification_version: 4
|
86
90
|
summary: A basic English dictionary spellchecker which returns the correctly spelled
|
metadata.gz.sig
CHANGED
Binary file
|