chat_correct 0.0.1 → 0.0.2
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
- data/README.md +6 -6
- data/chat_correct.gemspec +1 -1
- data/lib/chat_correct/correct.rb +3 -2
- data/lib/chat_correct/spelling.rb +3 -3
- data/lib/chat_correct/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acde234f5e17dabeb5812da984bcf25e4e9cfc59
|
4
|
+
data.tar.gz: 7f1522162906c9d89b576bdd5ce73e94cb8b2a77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f381bf523dcc848cd1513214194518e4bd53309bbb1afaf3cf68ca058891c1b8373a377722c98b01d4dad82dd35b150a6deff1f861748753418e32e0b4465f5f
|
7
|
+
data.tar.gz: b106388df4b51e0ef9b2c450126678c1735d08104247cd9922bf20d2b4e5159a4cb47d3762f8dc7bfa5256797090aae01a8576677a49546f723a3dea2d2d38e5
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ The correct method returns a hash of the original sentence interleaved with the
|
|
31
31
|
```ruby
|
32
32
|
os = "is the, puncttuation are wrong."
|
33
33
|
cs = "Is the punctuation wrong?"
|
34
|
-
cc = ChatCorrect.new(original_sentence: os, corrected_sentence: cs)
|
34
|
+
cc = ChatCorrect::Correct.new(original_sentence: os, corrected_sentence: cs)
|
35
35
|
cc.correct
|
36
36
|
|
37
37
|
# => {
|
@@ -92,7 +92,7 @@ The mistakes method returns a hash of each mistake, ordered by its position in t
|
|
92
92
|
```ruby
|
93
93
|
os = "is the, puncttuation are wrong."
|
94
94
|
cs = "Is the punctuation wrong?"
|
95
|
-
cc = ChatCorrect.new(original_sentence: os, corrected_sentence: cs)
|
95
|
+
cc = ChatCorrect::Correct.new(original_sentence: os, corrected_sentence: cs)
|
96
96
|
cc.mistakes
|
97
97
|
|
98
98
|
# => {
|
@@ -115,13 +115,13 @@ cc.mistakes
|
|
115
115
|
# 'correction' => 'punctuation'
|
116
116
|
# },
|
117
117
|
# 3 => {
|
118
|
-
# 'position' =>
|
118
|
+
# 'position' => 6,
|
119
119
|
# 'error_type' => 'unnecessary_word',
|
120
120
|
# 'mistake' => 'are',
|
121
121
|
# 'correction' => ''
|
122
122
|
# },
|
123
123
|
# 4 => {
|
124
|
-
# 'position' =>
|
124
|
+
# 'position' => 8,
|
125
125
|
# 'error_type' => 'punctuation',
|
126
126
|
# 'mistake' => '.',
|
127
127
|
# 'correction' => '?'
|
@@ -142,7 +142,7 @@ The mistake report method returns a hash containing the number of mistakes for e
|
|
142
142
|
```ruby
|
143
143
|
os = "is the, puncttuation are wrong."
|
144
144
|
cs = "Is the punctuation wrong?"
|
145
|
-
cc = ChatCorrect.new(original_sentence: os, corrected_sentence: cs)
|
145
|
+
cc = ChatCorrect::Correct.new(original_sentence: os, corrected_sentence: cs)
|
146
146
|
cc.mistake_report
|
147
147
|
# => {
|
148
148
|
# 'missing_word' => 0,
|
@@ -170,7 +170,7 @@ The number of mistakes method returns the total number of mistakes in the origin
|
|
170
170
|
```ruby
|
171
171
|
os = "is the, puncttuation are wrong."
|
172
172
|
cs = "Is the punctuation wrong?"
|
173
|
-
cc = ChatCorrect.new(original_sentence: os, corrected_sentence: cs)
|
173
|
+
cc = ChatCorrect::Correct.new(original_sentence: os, corrected_sentence: cs)
|
174
174
|
cc.number_of_mistakes
|
175
175
|
# => 5
|
176
176
|
```
|
data/chat_correct.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
|
-
spec.add_runtime_dependency "
|
24
|
+
spec.add_runtime_dependency "text"
|
25
25
|
spec.add_runtime_dependency "linguistics", "~> 2.0.2"
|
26
26
|
spec.add_runtime_dependency "verbs"
|
27
27
|
spec.add_runtime_dependency "engtagger"
|
data/lib/chat_correct/correct.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'engtagger'
|
2
|
+
require 'text'
|
2
3
|
|
3
4
|
module ChatCorrect
|
4
5
|
class Correct
|
@@ -297,7 +298,7 @@ module ChatCorrect
|
|
297
298
|
|
298
299
|
def stage_4(kc, vc, ks, vs)
|
299
300
|
return unless vc['token'].length > 3 && vs['token'].length > 3 &&
|
300
|
-
Levenshtein.distance(vc['token'], vs['token']) < 3 && !vc['matched']
|
301
|
+
Text::Levenshtein.distance(vc['token'], vs['token']) < 3 && !vc['matched']
|
301
302
|
write_match_to_info_hash(ks, kc, vc)
|
302
303
|
end
|
303
304
|
|
@@ -321,7 +322,7 @@ module ChatCorrect
|
|
321
322
|
# and 'the' that appear very far apart in the sentence and should not be matched.
|
322
323
|
return unless vc['token'].length > 1 &&
|
323
324
|
vs['token'].length > 1 &&
|
324
|
-
Levenshtein.distance(vc['token'], vs['token']) < 3 &&
|
325
|
+
Text::Levenshtein.distance(vc['token'], vs['token']) < 3 &&
|
325
326
|
vs['token'].to_s[0].eql?(vc['token'].to_s[0]) &&
|
326
327
|
(vs['position'].to_i - vc['position'].to_i).abs < 5 &&
|
327
328
|
!vc['matched']
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'text'
|
2
2
|
|
3
3
|
module ChatCorrect
|
4
4
|
class Spelling
|
@@ -12,9 +12,9 @@ module ChatCorrect
|
|
12
12
|
def spelling_error?
|
13
13
|
token_a.length > 1 && token_b.length > 1 &&
|
14
14
|
token_a.gsub(/[[:punct:]]/, "") != "" && token_b.gsub(/[[:punct:]]/, "") != "" &&
|
15
|
-
!(token_a[0] != token_b[0] && Levenshtein.distance(token_a.downcase, token_b.downcase) > 1) &&
|
15
|
+
!(token_a[0] != token_b[0] && Text::Levenshtein.distance(token_a.downcase, token_b.downcase) > 1) &&
|
16
16
|
!(WORD_CHOICE.include?(token_a.downcase) && WORD_CHOICE.include?(token_b.downcase)) &&
|
17
|
-
Levenshtein.distance(token_a.downcase, token_b.downcase) < 3 && token_a.downcase != token_b.downcase
|
17
|
+
Text::Levenshtein.distance(token_a.downcase, token_b.downcase) < 3 && token_a.downcase != token_b.downcase
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/chat_correct/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chat_correct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin S. Dias
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: text
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|