ru_bee 0.0.7 → 0.0.8
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 +8 -8
- data/README.md +44 -10
- data/lib/dictionary.rb +26 -0
- data/lib/ru_bee/version.rb +1 -1
- data/lib/scanner.rb +8 -18
- data/lib/suggestion.rb +1 -2
- data/ru_bee.gemspec +1 -1
- data/spec/dictionary_spec.rb +32 -0
- data/spec/scanner_spec.rb +0 -9
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODM4ZWFiNTliOTgwNjk5ODYwNGU0MTNlOTZmOTdjNzRhM2I0NzIwNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmQ2NWZhYjNhZGVkNjMyNjQzNjI1YjBhMmExNDVkMzZmYmU4ZWNkNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTQ1YmE4NTJlNGQzNjVmZjVjMWM5MDc3ZTk4NGU5YTE1ZWY1OWEwOGE3OTVl
|
10
|
+
NDUxZWZiM2EyMDUzNzIzN2RjYmYzNzgwMzQ2NzFkMDk4NWU2N2NmNzI1NTc2
|
11
|
+
NWUwNjU0YmYwNzY1MjcwOTViNTI1YTE1Zjk0NmFhNjIyNmM0MWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmQ4MTVhODVkNWU3MTA2YWI0MjI5MDZkNmJjODViMjYwNmVlZGM5MTIyODVk
|
14
|
+
YmQ1ZThlMjg5MjkxNDU3NzdhMmI4MGVhMGZiYjI5ZWQxZDMwZTQ5Y2Y1YjI5
|
15
|
+
ZGQ5ZmE5ZDRkMmVhMTZiMTQ3NmQ1MjMyMmZiMzM2NjAxMDliZGY=
|
data/README.md
CHANGED
@@ -21,7 +21,11 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
|
24
|
+
###correct?
|
25
|
+
|
26
|
+
```
|
27
|
+
#correct?
|
28
|
+
```
|
25
29
|
|
26
30
|
######boolean
|
27
31
|
|
@@ -29,22 +33,31 @@ Does the string contain a misspelling?
|
|
29
33
|
|
30
34
|
######arguments
|
31
35
|
|
32
|
-
|
36
|
+
```
|
37
|
+
#correct? language: 'english'
|
38
|
+
```
|
33
39
|
|
34
40
|
Other languages coming...
|
35
41
|
|
36
42
|
|
37
|
-
|
43
|
+
```ruby
|
44
|
+
"This is a correct sentence. It works well and is pretty cool. You can also use numbers 123!".correct?
|
45
|
+
```
|
38
46
|
|
39
47
|
##### `=> true`
|
40
48
|
|
41
|
-
|
49
|
+
```ruby
|
50
|
+
"This santence contains a typo.".correct?
|
51
|
+
```
|
42
52
|
|
43
53
|
##### `=> false`
|
44
54
|
|
45
55
|
|
56
|
+
##misspellings
|
46
57
|
|
47
|
-
|
58
|
+
```
|
59
|
+
#misspellings
|
60
|
+
```
|
48
61
|
|
49
62
|
######Array
|
50
63
|
|
@@ -52,19 +65,40 @@ Array of misspellings from String
|
|
52
65
|
|
53
66
|
######arguments
|
54
67
|
|
55
|
-
|
56
|
-
|
57
|
-
|
68
|
+
```
|
69
|
+
#misspellings? language: 'english'
|
70
|
+
```
|
58
71
|
|
59
|
-
|
72
|
+
```ruby
|
73
|
+
"This is a correct sentence. It works well and is pretty cool. You can also use numbers 123!".misspellings
|
74
|
+
```
|
60
75
|
|
61
76
|
##### `=> []`
|
62
77
|
|
63
|
-
|
78
|
+
```ruby
|
79
|
+
"This santence contains a typo.".misspellings
|
80
|
+
```
|
64
81
|
|
65
82
|
##### `=> ['santence']`
|
66
83
|
|
67
84
|
|
85
|
+
###suggestions
|
86
|
+
|
87
|
+
```
|
88
|
+
#misspellings(suggestions: true)
|
89
|
+
```
|
90
|
+
|
91
|
+
Returns array of hashes consisting of word and suggestions.
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
'fla'.misspellings suggestions: true
|
95
|
+
```
|
96
|
+
|
97
|
+
##### `=> [{word: 'fla', suggestions: ["acriflavin", "acriflavine"...]}]`
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
68
102
|
## Contributing
|
69
103
|
|
70
104
|
#### Dictionaries
|
data/lib/dictionary.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
class Dictionary
|
2
|
+
|
3
|
+
def initialize options={}
|
4
|
+
@options = options
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.instance options={}
|
8
|
+
@instance ||= new(options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def contents
|
12
|
+
@contents ||= begin
|
13
|
+
filename = @options[:language] || 'english'
|
14
|
+
path = File.dirname(__FILE__)
|
15
|
+
file = File.open("#{path}/dictionaries/#{filename}", "r")
|
16
|
+
contents = file.read.downcase.split(/\n/)
|
17
|
+
file.close
|
18
|
+
contents || []
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def check word
|
23
|
+
contents.include?(word)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/ru_bee/version.rb
CHANGED
data/lib/scanner.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'suggestion'
|
2
|
+
require 'dictionary'
|
2
3
|
|
3
4
|
class String
|
4
5
|
|
@@ -19,17 +20,6 @@ class String
|
|
19
20
|
@words ||= self.downcase.gsub(/[\'\"]/, '').scan(/[a-z]+/)
|
20
21
|
end
|
21
22
|
|
22
|
-
def dictionary
|
23
|
-
@dictionary ||= begin
|
24
|
-
filename = @options[:language] || 'english'
|
25
|
-
path = File.dirname(__FILE__)
|
26
|
-
file = File.open("#{path}/dictionaries/#{filename}", "r")
|
27
|
-
contents = file.read.downcase.split(/\n/)
|
28
|
-
file.close
|
29
|
-
contents || []
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
23
|
def remove_s word
|
34
24
|
if word[-1] == 's'
|
35
25
|
return word[0...-1]
|
@@ -59,15 +49,15 @@ class String
|
|
59
49
|
end
|
60
50
|
|
61
51
|
def check opts={}
|
52
|
+
dictionary = Dictionary.instance @options
|
62
53
|
@bad_words = []
|
63
54
|
words.each do |word|
|
64
|
-
unless dictionary.
|
65
|
-
dictionary.
|
66
|
-
dictionary.
|
67
|
-
dictionary.
|
68
|
-
dictionary.
|
69
|
-
|
70
|
-
@bad_words << (opts[:suggestions] ? suggestion.search : word)
|
55
|
+
unless dictionary.check("#{word}") or
|
56
|
+
dictionary.check("#{remove_s(word)}") or
|
57
|
+
dictionary.check("#{remove_ed(word)}") or
|
58
|
+
dictionary.check("#{remove_ing(word)}") or
|
59
|
+
dictionary.check("#{remove_es(word)}")
|
60
|
+
@bad_words << (opts[:suggestions] ? (Suggestion.new(word, dictionary.contents).search) : word)
|
71
61
|
return false unless opts[:collect]
|
72
62
|
end
|
73
63
|
end
|
data/lib/suggestion.rb
CHANGED
data/ru_bee.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["dan"]
|
10
10
|
spec.email = ["danbickford007@yahoo.com"]
|
11
11
|
spec.summary = %q{Dictionary for Ruby String.}
|
12
|
-
spec.description = %q{
|
12
|
+
spec.description = %q{Checks Ruby String for misspellings. Usage: 'this is a test'.correct? 'this is a test'.misspellings(suggestions: true)}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'dictionary'
|
2
|
+
|
3
|
+
describe Dictionary do
|
4
|
+
|
5
|
+
let(:dictionary) { Dictionary.instance {}}
|
6
|
+
|
7
|
+
describe '#contents' do
|
8
|
+
|
9
|
+
it 'should have x amount contents' do
|
10
|
+
expect(dictionary.contents.count).to eq(235887)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.instance' do
|
16
|
+
|
17
|
+
it 'should only have 1 instance' do
|
18
|
+
dict = Dictionary.instance
|
19
|
+
expect(dictionary.object_id).to eq(dict.object_id)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#check' do
|
25
|
+
|
26
|
+
it 'should word exists in contents' do
|
27
|
+
expect(dictionary.check('test')).to eq(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/spec/scanner_spec.rb
CHANGED
@@ -50,15 +50,6 @@ describe String do
|
|
50
50
|
|
51
51
|
end
|
52
52
|
|
53
|
-
describe '#load_dictionary' do
|
54
|
-
|
55
|
-
it 'should set DICTIONARY to' do
|
56
|
-
test_string_good.correct?
|
57
|
-
expect(test_string_good.send('dictionary').count).to eq(235887)
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
53
|
describe '#remove_s' do
|
63
54
|
|
64
55
|
it 'should trim plural to singluar with s' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ru_bee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dan
|
@@ -52,7 +52,8 @@ dependencies:
|
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.2.0
|
55
|
-
description:
|
55
|
+
description: ! 'Checks Ruby String for misspellings. Usage: ''this is a test''.correct? ''this
|
56
|
+
is a test''.misspellings(suggestions: true)'
|
56
57
|
email:
|
57
58
|
- danbickford007@yahoo.com
|
58
59
|
executables: []
|
@@ -65,6 +66,7 @@ files:
|
|
65
66
|
- README.md
|
66
67
|
- Rakefile
|
67
68
|
- lib/dictionaries/english
|
69
|
+
- lib/dictionary.rb
|
68
70
|
- lib/ru_bee.rb
|
69
71
|
- lib/ru_bee/version.rb
|
70
72
|
- lib/scanner.rb
|
@@ -72,6 +74,7 @@ files:
|
|
72
74
|
- ru_bee-0.0.2.gem
|
73
75
|
- ru_bee.gemspec
|
74
76
|
- ru_bee_string.rb
|
77
|
+
- spec/dictionary_spec.rb
|
75
78
|
- spec/scanner_spec.rb
|
76
79
|
- spec/suggestion_spec.rb
|
77
80
|
homepage: ''
|
@@ -99,5 +102,6 @@ signing_key:
|
|
99
102
|
specification_version: 4
|
100
103
|
summary: Dictionary for Ruby String.
|
101
104
|
test_files:
|
105
|
+
- spec/dictionary_spec.rb
|
102
106
|
- spec/scanner_spec.rb
|
103
107
|
- spec/suggestion_spec.rb
|