confidential_info_redactor_lite 1.0.5 → 1.0.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e591d6c6ad041c36fd2c70ae92fb92df5ef5b988
|
4
|
+
data.tar.gz: 392b6e548ca876c04c1a1d747ca6753d82c73433
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4b626fcd913d8a33e542a2b3396c3a137719fbca95e8d151e59b178aef09206d754711dc986c6e5d6a99a7ac42721ea6a111acbe8090ca5dc9045d94bf9a68c
|
7
|
+
data.tar.gz: 7b270a2fa019c54d4ab9688c6cd2f20c8182506d1c2faea43d95b378e572e52723fecc2d4352ea7a47113c7e2a5b0e77ec67847d15e14331606fef5a07a58623
|
@@ -153,6 +153,7 @@ module ConfidentialInfoRedactorLite
|
|
153
153
|
redacted_text.split(' ').each_with_index do |redacted_token, index|
|
154
154
|
if redacted_token.gsub(/\./, '') == date_text
|
155
155
|
original_sentence_array.each_with_index do |original_token, i|
|
156
|
+
date_tokens << original_token if original_sentence_array.length == 1
|
156
157
|
if redacted_sentence_array[index - 1] == original_token &&
|
157
158
|
diff.include?(original_sentence_array[i + 1]) &&
|
158
159
|
original_sentence_array[i + 2] == redacted_sentence_array[index + 1]
|
@@ -192,7 +193,7 @@ module ConfidentialInfoRedactorLite
|
|
192
193
|
end
|
193
194
|
|
194
195
|
def redact_dates(txt)
|
195
|
-
ConfidentialInfoRedactorLite::Date.new(dow: dow, dow_abbr: dow_abbr, months: months, months_abbr: months_abbr).replace(txt).gsub(/<redacted date>/, "#{date_text}").gsub(/\s*#{Regexp.escape(date_text)}\s*/, " #{date_text} ").gsub(/\A\s*#{Regexp.escape(date_text)}\s*/, "#{date_text} ").gsub(/#{Regexp.escape(date_text)}\s{1}\.{1}/, "#{date_text}.")
|
196
|
+
ConfidentialInfoRedactorLite::Date.new(dow: dow, dow_abbr: dow_abbr, months: months, months_abbr: months_abbr).replace(txt).gsub(/<redacted date>/, "#{date_text}").gsub(/\s*#{Regexp.escape(date_text)}\s*/, " #{date_text} ").gsub(/\A\s*#{Regexp.escape(date_text)}\s*/, "#{date_text} ").gsub(/#{Regexp.escape(date_text)}\s{1}\.{1}/, "#{date_text}.").strip
|
196
197
|
end
|
197
198
|
|
198
199
|
def redact_numbers(txt)
|
@@ -6,6 +6,10 @@ RSpec.describe ConfidentialInfoRedactorLite::Redactor do
|
|
6
6
|
let(:en_dow_abbr) { %w(mon tu tue tues wed th thu thur thurs fri sat sun) }
|
7
7
|
let(:en_months) { %w(january february march april may june july august september october november december) }
|
8
8
|
let(:en_month_abbr) { %w(jan feb mar apr jun jul aug sep sept oct nov dec) }
|
9
|
+
let(:de_dow) { %w(montag dienstag mittwoch donnerstag freitag samstag sonntag sonnabend) }
|
10
|
+
let(:de_dow_abbr) { %w(mo di mi do fr sa so) }
|
11
|
+
let(:de_months) { %w(januar februar märz april mai juni juli august september oktober november dezember) }
|
12
|
+
let(:de_month_abbr) { %w(jan jän feb märz apr mai juni juli aug sep sept okt nov dez) }
|
9
13
|
|
10
14
|
describe '#dates' do
|
11
15
|
it 'handles nil as a text argument' do
|
@@ -32,6 +36,11 @@ RSpec.describe ConfidentialInfoRedactorLite::Redactor do
|
|
32
36
|
expect(described_class.new(language: 'en', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).dates(text)).to eq('The scavenger hunt ends on <redacted date>.')
|
33
37
|
end
|
34
38
|
|
39
|
+
it 'redacts dates from a text #004' do
|
40
|
+
text = '18/01/2013'
|
41
|
+
expect(described_class.new(language: 'de', dow: de_dow, dow_abbr: de_dow_abbr, months: de_months, months_abbr: de_month_abbr).dates(text)).to eq('<redacted date>')
|
42
|
+
end
|
43
|
+
|
35
44
|
it 'handles nil date objects' do
|
36
45
|
text = 'The scavenger hunt ends on Dec. 31st, 2011.'
|
37
46
|
expect(described_class.new(language: 'en', dow: nil, dow_abbr: nil, months: nil, months_abbr: nil).dates(text)).to eq('The scavenger hunt ends on Dec. 31st, 2011.')
|
@@ -62,6 +71,11 @@ RSpec.describe ConfidentialInfoRedactorLite::Redactor do
|
|
62
71
|
text = '2011年12月31日です。'
|
63
72
|
expect(described_class.new(language: 'ja', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr, date_text: "*****").dates_html(text)).to eq(["<span class='confidentialDate'>*****</span> です。", ["2011年12月31日"]])
|
64
73
|
end
|
74
|
+
|
75
|
+
it 'surrounds the redacted dates in spans and return the redacted dates from a text #003' do
|
76
|
+
text = '18/01/2013'
|
77
|
+
expect(described_class.new(language: 'de', dow: de_dow, dow_abbr: de_dow_abbr, months: de_months, months_abbr: de_month_abbr, date_text: "*****").dates_html(text)[1]).to eq(['18/01/2013'])
|
78
|
+
end
|
65
79
|
end
|
66
80
|
|
67
81
|
describe '#numbers' do
|
@@ -150,6 +164,11 @@ RSpec.describe ConfidentialInfoRedactorLite::Redactor do
|
|
150
164
|
text = "machine width – 3900mm (overall), 3500mm (cross members)"
|
151
165
|
expect(described_class.new(language: 'en', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr, number_text: "*****").numbers_html(text)).to eq(["machine width – <span class='confidentialNumber'>*****</span> (overall), <span class='confidentialNumber'>*****</span> (cross members)", ["3900mm", "3500mm"]])
|
152
166
|
end
|
167
|
+
|
168
|
+
it 'surrounds the redacted numbers in spans and return the redacted numbers from a text #004' do
|
169
|
+
text = "Page 1500"
|
170
|
+
expect(described_class.new(language: 'en', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr, number_text: "*****").numbers_html(text)[1]).to eq(["1500"])
|
171
|
+
end
|
153
172
|
end
|
154
173
|
|
155
174
|
describe '#emails' do
|
@@ -270,7 +289,7 @@ RSpec.describe ConfidentialInfoRedactorLite::Redactor do
|
|
270
289
|
Don’t forget to use your imagination and creativity!
|
271
290
|
EOF
|
272
291
|
tokens = ConfidentialInfoRedactorLite::Extractor.new(corpus: corpus).extract(text)
|
273
|
-
expect(described_class.new(language: 'en', tokens: tokens, dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).redact(text)).to eq("
|
292
|
+
expect(described_class.new(language: 'en', tokens: tokens, dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).redact(text)).to eq("<redacted>\n\n <redacted> is hosting the <redacted number> <redacted>. So get out your putter and your camera and see if you have what it takes. Are you a <redacted>?\n\n <redacted>: <redacted number>) <redacted> of <redacted number> professional miniature golfers, each from a different country. (<redacted number> points; <redacted number> bonus points if the professional miniature golfers are also from <redacted number> different continents) <redacted number>) <redacted> of yourself next to each obstacle in our list of the Top <redacted number> <redacted>. (<redacted number> points; <redacted number> bonus points for each obstacle that exactly matches the one pictured in the article) <redacted number>) <redacted> your own full-size miniature golf hole. (<redacted number> points; up to <redacted number> bonus points available depending on the craftsmanship, playability, creativity and fun factor of your hole) <redacted number>) <redacted> of yourself making a hole-in-one on two consecutive miniature golf holes. <redacted> video must be one continuous shot with no editing. (<redacted number> points) <redacted number>) <redacted> of yourself with the <redacted> mascot. (<redacted number> points; <redacted number> bonus points if you are wearing a <redacted> t-shirt) <redacted number>) <redacted> of yourself with the completed <redacted> wobblehead. (<redacted number> points; <redacted number> bonus points if the picture is taken at a miniature golf course) <redacted number>) <redacted> of a completed scorecard from a round of miniature golf. <redacted> round of golf must have taken place after the start of this scavenger hunt. (<redacted number> points) <redacted number>) <redacted> of completed scorecards from <redacted number> different miniature golf courses. <redacted> round of golf must have taken place after the start of this scavenger hunt. (<redacted number> points) <redacted number>) <redacted> an entry to the <redacted number> <redacted>. (<redacted number> points; <redacted number> bonus points if your entry gets more than <redacted number> votes) <redacted number>) <redacted> from the <redacted> app showing a 9-hole score below par. (<redacted number> points) <redacted number>) <redacted> from the <redacted> app showing that you have successfully unlocked all of the holes in the game. (<redacted number> points) <redacted number>) <redacted> of the <redacted> wobblehead at a <redacted>. (<redacted number> points) <redacted number>) <redacted> and submit the <redacted> ‘Practice <redacted>’ and ‘Final <redacted>’ for any one of the <redacted> math or physics lessons. (<redacted number> points; <redacted number> bonus points if you complete two lessons) <redacted number>) <redacted> of yourself with at least <redacted number> different colored miniature golf balls. (<redacted number> points; <redacted number> bonus points for each additional color {limit of <redacted number> bonus points}) <redacted number>) <redacted> of yourself with a famous golfer or miniature golfer. (<redacted number> points; <redacted number> bonus points if the golfer is on the <redacted> tour <redacted> you are wearing a <redacted> t-shirt in the picture) <redacted number>) <redacted> of yourself making a hole-in-one on a miniature golf hole with a loop-de-loop obstacle. (<redacted number> points) <redacted number>) <redacted> of yourself successfully making a trick miniature golf shot. (<redacted number> points; up to <redacted number> bonus points available depending on the difficulty and complexity of the trick shot)\n\n\n Prizes: <redacted number> <redacted> <redacted>\n\n <redacted>\n (<redacted number> <redacted number> <redacted> - <redacted>)\n\n <redacted> team will judge the scavenger hunt and all decisions will be final. <redacted> is sponsoring it. <redacted> scavenger hunt is open to anyone and everyone. <redacted> scavenger hunt ends on <redacted date>.\n\n <redacted> enter the scavenger hunt, send an email to info <redacted> putterking <redacted> com with the subject line: \"<redacted>\". In the email please include links to the pictures and videos you are submitting. You can utilize free photo and video hosting sites such as <redacted>, <redacted>, <redacted>, <redacted>, etc. for your submissions.\n\n <redacted> entering the <redacted>, you allow <redacted> to use or link to any of the pictures or videos you submit for advertisements and promotions.\n\n Don’t forget to use your imagination and creativity!")
|
274
293
|
end
|
275
294
|
|
276
295
|
it 'redacts all confidential information from a text #003' do
|