english_spellchecker 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/lib/english_spellchecker.rb +70 -9
- data.tar.gz.sig +0 -0
- metadata +28 -24
- 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: d118ffc67e55e9143620181f273940f4f7e7be2eb2b0de812e33d8783e18fe75
|
4
|
+
data.tar.gz: f6f00e8be81fea8f9c8dba4e143fbd4797b85dd103906720f33ede1e983a0d77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 537814cd8b0f61782c5a4daa438f2142b0d2aa2c9d08f94a344ee8b532fd41ed50b7df76e934eb0d766cbfa68bffe5d76da6f6152de5a97cc41e37b85a78cf71
|
7
|
+
data.tar.gz: 83c9c99457a609e817ccd53cbe66c81c6914daed5adca6ef863218e654dbe2ca2f2711d148490c86565ee0bc66fc454f65a717c4e28c9202c416edbb4d4a25f2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/english_spellchecker.rb
CHANGED
@@ -3,30 +3,91 @@
|
|
3
3
|
# file: english_spellchecker.rb
|
4
4
|
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'words2dotdat'
|
7
7
|
require 'did_you_mean'
|
8
8
|
|
9
9
|
|
10
10
|
class EnglishSpellcheck
|
11
|
+
|
12
|
+
@words = Words2DotDat.words
|
11
13
|
|
12
14
|
def initialize()
|
13
|
-
@
|
15
|
+
@words = Words2DotDat.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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,31 +10,36 @@ 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+w2OD4MTFvARAlreTxjv8EH61w1g9ksU3JqIvZ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+/ZsTIbvqJNOO6FbHl2q4hcdLO6fgW+cXpUf17efgIY1CnDj0auhLsW
|
36
|
+
i/2txSflqYUUrcpt7Nw/jBhIhPD17gtkt93TyMkMATK8LOOiRBzUeSoLmcUZV/cd
|
37
|
+
Os7I/4C4AaEaqtRAvendPVG41n9/F/5Hp2c=
|
33
38
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
39
|
+
date: 2022-11-02 00:00:00.000000000 Z
|
35
40
|
dependencies:
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
42
|
+
name: words2dotdat
|
38
43
|
requirement: !ruby/object:Gem::Requirement
|
39
44
|
requirements:
|
40
45
|
- - "~>"
|
@@ -54,7 +59,7 @@ dependencies:
|
|
54
59
|
- !ruby/object:Gem::Version
|
55
60
|
version: 0.1.1
|
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
|