ru_bee 0.0.4 → 0.0.5
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 +22 -0
- data/lib/ru_bee/version.rb +1 -1
- data/lib/scanner.rb +12 -2
- data/spec/scanner_spec.rb +19 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjE4ZTQ0YmJhOGY2MWE4NGM5ZGU2ZDRmMzQ1ZjYwMGM1NWJiYWI3OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODA3NTNhYmU3ZTM4YjAyYmFjZDZhN2M1Nzg1MzU2NzM3MjlkODRlNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmM0YTEzYjFmMWNjZjcxYTYyODU1NDQzMGZkNGZmYWFiODliMGU3OTA5MTBh
|
10
|
+
Njg4ZDlhNmZmM2E5NzIzZTRmNzAwYjU3N2JjNGZiYjhjNjhkYjdlN2Q1ZDFj
|
11
|
+
ZTRkYmY5MmIwZWE0ZWVkMzIwYTc1ODNkNWE5ZDE0YTZjYTFkNjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzgzYTMxODcxM2NjOGQwZTExYzk3ZWM2MDYxZjA0ZmNmMDZkOWM0NGRmNTJk
|
14
|
+
ZGFkNWYxYzhlYjEwMjEyMmE2YTAxZWE3NzEzYzE5OGMwNDBkYWVjYTdhYjU4
|
15
|
+
OGNiYjI0NjBlYjhkMzgyYjU3NmI0M2ZiZDQ4ZjFmNzE4YTNkY2M=
|
data/README.md
CHANGED
@@ -43,6 +43,28 @@ Other languages coming...
|
|
43
43
|
##### `=> false`
|
44
44
|
|
45
45
|
|
46
|
+
|
47
|
+
`#misspellings`
|
48
|
+
|
49
|
+
######Array
|
50
|
+
|
51
|
+
Array of misspellings from String
|
52
|
+
|
53
|
+
######arguments
|
54
|
+
|
55
|
+
`#misspellings? language: 'english'`
|
56
|
+
|
57
|
+
Other languages coming...
|
58
|
+
|
59
|
+
`"This is a correct sentence. It works well and is pretty cool. You can also use numbers 123!".misspellings`
|
60
|
+
|
61
|
+
##### `=> []`
|
62
|
+
|
63
|
+
`"This santence contains a typo.".correct?`
|
64
|
+
|
65
|
+
##### `=> ['santence']`
|
66
|
+
|
67
|
+
|
46
68
|
## Contributing
|
47
69
|
|
48
70
|
#### Dictionaries
|
data/lib/ru_bee/version.rb
CHANGED
data/lib/scanner.rb
CHANGED
@@ -10,6 +10,14 @@ class String
|
|
10
10
|
check
|
11
11
|
end
|
12
12
|
|
13
|
+
def misspellings options={}
|
14
|
+
@options = options
|
15
|
+
get_parts
|
16
|
+
load_dictionary
|
17
|
+
check true
|
18
|
+
@bad_words
|
19
|
+
end
|
20
|
+
|
13
21
|
private
|
14
22
|
|
15
23
|
def get_parts
|
@@ -53,14 +61,16 @@ class String
|
|
53
61
|
word
|
54
62
|
end
|
55
63
|
|
56
|
-
def check
|
64
|
+
def check collect=false
|
65
|
+
@bad_words = []
|
57
66
|
@parts.each do |word|
|
58
67
|
unless @dictionary.include?("#{word}") or
|
59
68
|
@dictionary.include?("#{remove_s(word)}") or
|
60
69
|
@dictionary.include?("#{remove_ed(word)}") or
|
61
70
|
@dictionary.include?("#{remove_ing(word)}") or
|
62
71
|
@dictionary.include?("#{remove_es(word)}")
|
63
|
-
|
72
|
+
@bad_words << word
|
73
|
+
return false unless collect
|
64
74
|
end
|
65
75
|
end
|
66
76
|
true
|
data/spec/scanner_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'scanner'
|
|
3
3
|
describe String do
|
4
4
|
|
5
5
|
let(:test_string_good) { "This is a test string. It doesn't have 123 any issues." }
|
6
|
-
let(:test_string_bad) { "This is a test string. But it conaens a bad word." }
|
6
|
+
let(:test_string_bad) { "This is a test string. But it conaens a bad word. bergerb" }
|
7
7
|
|
8
8
|
|
9
9
|
describe '#correct?' do
|
@@ -18,6 +18,23 @@ describe String do
|
|
18
18
|
|
19
19
|
end
|
20
20
|
|
21
|
+
describe '#misspellings' do
|
22
|
+
|
23
|
+
it 'should return array of misspelled words' do
|
24
|
+
expect(test_string_bad.misspellings).to eq(['conaens', 'bergerb'])
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should return array length of 2' do
|
28
|
+
expect(test_string_bad.misspellings.count).to eq(2)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should return array empty array if all correct' do
|
32
|
+
expect(test_string_good.misspellings.count).to eq(0)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
|
21
38
|
describe '#get_parts' do
|
22
39
|
|
23
40
|
it 'should break string into word parts' do
|
@@ -67,4 +84,5 @@ describe String do
|
|
67
84
|
|
68
85
|
end
|
69
86
|
|
87
|
+
|
70
88
|
end
|