chat_correct 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfcb30b6d537455888810e34146a4207e5c768ac
4
- data.tar.gz: 1a647ede3674ab79cd9eba2edaf84b3c09f1dd6b
3
+ metadata.gz: a3c1125d076cc373a05732ae72b73cf765a7c224
4
+ data.tar.gz: ae70fb4edcbc9496bdb6dba95bdcd132d7232a15
5
5
  SHA512:
6
- metadata.gz: 113770db887825354e1770fe5833f3b6b1ef63e82d7fcc188c40f4f8bace0460253aa524fa41979b152a477f1a7fda8d5a0949c7f4ac736a60bc0225249a3c09
7
- data.tar.gz: b5b10196bb691bab5bbf3785ad5ffd9863c936b4dccfe3bea032348678332fd5de272ddfbf62041eef06407324eb51453920c04837b60a505f95f7b46571b95d
6
+ metadata.gz: 9b88d5e0e976dc93adc26d0b2e3ef9e55c45a5c49877b968e9d021bc11c6290c4450b7c1a68d968c90efb53c9da05d563a9bd97bd583baae4691b4b5df5aa9f9
7
+ data.tar.gz: 37f587c0abfe10c0bf39386ec82d4614a8cbbeed1d95044cb14ed4c160edf10ade74434ff588b0f433e5346580209b23c2f3e4f1cafce73673d3625a839c315e
@@ -17,20 +17,7 @@ module ChatCorrect
17
17
  mistakes_hash = {}
18
18
  analyze.each do |key, value|
19
19
  next if !value['type'].split('_')[-1].eql?('mistake') || value['type'].split('_')[0].eql?('no')
20
- interim_hash = {}
21
- interim_hash['position'] = key
22
- if value['type'].split('_').length > 2
23
- interim_hash['error_type'] = value['type'].split('_')[0] + '_' + value['type'].split('_')[1]
24
- else
25
- interim_hash['error_type'] = value['type'].split('_')[0]
26
- end
27
- interim_hash['mistake'] = value['token']
28
- if correct[key + 1]['type'].split('_')[0].eql?(correct[key]['type'].split('_')[0])
29
- interim_hash['correction'] = correct[key + 1]['token']
30
- else
31
- interim_hash['correction'] = ''
32
- end
33
- mistakes_hash[mistakes_hash.length] = interim_hash
20
+ mistakes_hash = build_mistakes_hash(mistakes_hash, key, value)
34
21
  end
35
22
  mistakes_hash
36
23
  end
@@ -82,6 +69,34 @@ module ChatCorrect
82
69
  build_corrections_hash(correction_hash)
83
70
  end
84
71
 
72
+ def update_interim_hash_with_error(interim_hash, value)
73
+ if value['type'].split('_').length > 2
74
+ interim_hash['error_type'] = value['type'].split('_')[0] + '_' + value['type'].split('_')[1]
75
+ else
76
+ interim_hash['error_type'] = value['type'].split('_')[0]
77
+ end
78
+ interim_hash
79
+ end
80
+
81
+ def update_interim_hash_with_correction(interim_hash, key)
82
+ if correct[key + 1]['type'].split('_')[0].eql?(correct[key]['type'].split('_')[0])
83
+ interim_hash['correction'] = correct[key + 1]['token']
84
+ else
85
+ interim_hash['correction'] = ''
86
+ end
87
+ interim_hash
88
+ end
89
+
90
+ def build_mistakes_hash(mistakes_hash, key, value)
91
+ interim_hash = {}
92
+ interim_hash['position'] = key
93
+ interim_hash = update_interim_hash_with_error(interim_hash, value)
94
+ interim_hash['mistake'] = value['token']
95
+ interim_hash = update_interim_hash_with_correction(interim_hash, key) unless correct[key + 1].blank?
96
+ mistakes_hash[mistakes_hash.length] = interim_hash
97
+ mistakes_hash
98
+ end
99
+
85
100
  def build_corrections_hash(correction_hash)
86
101
  final_hash = {}
87
102
  correction_hash.each do |k, v|
@@ -1,3 +1,3 @@
1
1
  module ChatCorrect
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -200,13 +200,13 @@ RSpec.describe ChatCorrect::Correct do
200
200
  expect(@cc.correct).to eq({0=>{"token"=>"This", "type"=>"no_mistake"}, 1=>{"token"=>"is", "type"=>"no_mistake"}, 2=>{"token"=>"and", "type"=>"no_mistake"}, 3=>{"token"=>"this", "type"=>"no_mistake"}, 4=>{"token"=>"and", "type"=>"no_mistake"}, 5=>{"token"=>"this", "type"=>"no_mistake"}, 6=>{"token"=>"is", "type"=>"no_mistake"}, 7=>{"token"=>"a", "type"=>"no_mistake"}, 8=>{"token"=>"correct", "type"=>"no_mistake"}, 9=>{"token"=>"double", "type"=>"no_mistake"}, 10=>{"token"=>"word", "type"=>"no_mistake"}, 11=>{"token"=>"check", "type"=>"no_mistake"}, 12=>{"token"=>"!", "type"=>"punctuation_mistake"}, 13=>{"token"=>".", "type"=>"punctuation_correction"}})
201
201
  end
202
202
 
203
- # it 'Counts the number of mistakes' do
204
- # expect(@cc.number_of_mistakes).to eq([])
205
- # end
203
+ it 'Counts the number of mistakes' do
204
+ expect(@cc.number_of_mistakes).to eq(1)
205
+ end
206
206
 
207
- # it 'Reports the mistakes by mistake type' do
208
- # expect(@cc.mistake_report).to eq([])
209
- # end
207
+ it 'Reports the mistakes by mistake type' do
208
+ expect(@cc.mistake_report).to eq({"missing_word"=>0, "unnecessary_word"=>0, "spelling"=>0, "verb"=>0, "punctuation"=>1, "word_order"=>0, "capitalization"=>0, "duplicate_word"=>0, "word_choice"=>0, "pluralization"=>0, "possessive"=>0, "stylistic_choice"=>0})
209
+ end
210
210
  end
211
211
 
212
212
  context "example correction #011" do
@@ -220,13 +220,13 @@ RSpec.describe ChatCorrect::Correct do
220
220
  expect(@cc.correct).to eq({0=>{"token"=>"He", "type"=>"no_mistake"}, 1=>{"token"=>"said", "type"=>"no_mistake"}, 2=>{"token"=>",", "type"=>"no_mistake"}, 3=>{"token"=>"\"", "type"=>"no_mistake"}, 4=>{"token"=>"Shhe", "type"=>"spelling_mistake"}, 5=>{"token"=>"She", "type"=>"spelling_correction"}, 6=>{"token"=>"is", "type"=>"no_mistake"}, 7=>{"token"=>"a", "type"=>"no_mistake"}, 8=>{"token"=>"crazy", "type"=>"no_mistake"}, 9=>{"token"=>"girl", "type"=>"no_mistake"}, 10=>{"token"=>".", "type"=>"word_order_mistake"}, 11=>{"token"=>"\"", "type"=>"word_order_mistake"}})
221
221
  end
222
222
 
223
- # it 'Counts the number of mistakes' do
224
- # expect(@cc.number_of_mistakes).to eq([])
225
- # end
223
+ it 'Counts the number of mistakes' do
224
+ expect(@cc.number_of_mistakes).to eq(3)
225
+ end
226
226
 
227
- # it 'Reports the mistakes by mistake type' do
228
- # expect(@cc.mistake_report).to eq([])
229
- # end
227
+ it 'Reports the mistakes by mistake type' do
228
+ expect(@cc.mistake_report).to eq({"missing_word"=>0, "unnecessary_word"=>0, "spelling"=>1, "verb"=>0, "punctuation"=>0, "word_order"=>2, "capitalization"=>0, "duplicate_word"=>0, "word_choice"=>0, "pluralization"=>0, "possessive"=>0, "stylistic_choice"=>0})
229
+ end
230
230
  end
231
231
 
232
232
  context "example correction #012" do
@@ -240,13 +240,13 @@ RSpec.describe ChatCorrect::Correct do
240
240
  expect(@cc.correct).to eq({0=>{"token"=>"Test", "type"=>"no_mistake"}, 1=>{"token"=>"the", "type"=>"no_mistake"}, 2=>{"token"=>"word", "type"=>"word_order_mistake"}, 3=>{"token"=>"order", "type"=>"word_order_mistake"}, 4=>{"token"=>".", "type"=>"no_mistake"}})
241
241
  end
242
242
 
243
- # it 'Counts the number of mistakes' do
244
- # expect(@cc.number_of_mistakes).to eq([])
245
- # end
243
+ it 'Counts the number of mistakes' do
244
+ expect(@cc.number_of_mistakes).to eq(2)
245
+ end
246
246
 
247
- # it 'Reports the mistakes by mistake type' do
248
- # expect(@cc.mistake_report).to eq([])
249
- # end
247
+ it 'Reports the mistakes by mistake type' do
248
+ expect(@cc.mistake_report).to eq({"missing_word"=>0, "unnecessary_word"=>0, "spelling"=>0, "verb"=>0, "punctuation"=>0, "word_order"=>2, "capitalization"=>0, "duplicate_word"=>0, "word_choice"=>0, "pluralization"=>0, "possessive"=>0, "stylistic_choice"=>0})
249
+ end
250
250
  end
251
251
 
252
252
  context "example correction #013" do
@@ -260,13 +260,13 @@ RSpec.describe ChatCorrect::Correct do
260
260
  expect(@cc.correct).to eq({0=>{"token"=>"This", "type"=>"no_mistake"}, 1=>{"token"=>"is", "type"=>"no_mistake"}, 2=>{"token"=>"a", "type"=>"no_mistake"}, 3=>{"token"=>"double", "type"=>"duplicate_word_mistake"}, 4=>{"token"=>"double", "type"=>"duplicate_word_mistake"}, 5=>{"token"=>"double", "type"=>"duplicate_word_mistake"}, 6=>{"token"=>"double", "type"=>"no_mistake"}, 7=>{"token"=>"word", "type"=>"no_mistake"}, 8=>{"token"=>"check", "type"=>"no_mistake"}, 9=>{"token"=>".", "type"=>"no_mistake"}})
261
261
  end
262
262
 
263
- # it 'Counts the number of mistakes' do
264
- # expect(@cc.number_of_mistakes).to eq([])
265
- # end
263
+ it 'Counts the number of mistakes' do
264
+ expect(@cc.number_of_mistakes).to eq(3)
265
+ end
266
266
 
267
- # it 'Reports the mistakes by mistake type' do
268
- # expect(@cc.mistake_report).to eq([])
269
- # end
267
+ it 'Reports the mistakes by mistake type' do
268
+ expect(@cc.mistake_report).to eq({"missing_word"=>0, "unnecessary_word"=>0, "spelling"=>0, "verb"=>0, "punctuation"=>0, "word_order"=>0, "capitalization"=>0, "duplicate_word"=>3, "word_choice"=>0, "pluralization"=>0, "possessive"=>0, "stylistic_choice"=>0})
269
+ end
270
270
  end
271
271
 
272
272
  context "example correction #014" do
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin S. Dias