confidential_info_redactor 0.0.2 → 0.0.3
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: 53df3b59f337fc1c1975f4cc37701bce82867bea
|
4
|
+
data.tar.gz: 48619c48b24dcc0fdfc6b407f911045f4c5286c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b63e2e817891fe6fe20664f7b0dd279193015ad6b491303914593f2955c1941e1277e3f58b4eff7e9d166378f7b4455cb8143b0df51413bdbe068a01df295d9f
|
7
|
+
data.tar.gz: 66af11baec2a927039becc83da9366d5beea1c8fcb263ec15c78af4b6f3ac5558566fb18e624e4f9e0a530598d4834d47998ab8ee97bb18f52b4ff6327ec7ac6
|
data/README.md
CHANGED
@@ -74,7 +74,8 @@ ConfidentialInfoRedactor::Redactor.new(text: text, language: 'de', tokens: token
|
|
74
74
|
# => 'Viele Mitarbeiter der <redacted> suchen eine andere Arbeitsstelle.'
|
75
75
|
|
76
76
|
# It is also possible to change the redaction text
|
77
|
-
|
77
|
+
text = 'Coca-Cola announced a merger with Pepsi that will happen on December 15th, 2020 for $200,000,000,000. Please contact John Smith at j.smith@example.com or visit http://www.super-fake-merger.com.'
|
78
|
+
tokens = ['Coca-Cola', 'Pepsi', 'John Smith']
|
78
79
|
ConfidentialInfoRedactor::Redactor.new(text: text, tokens: tokens, number_text: '**redacted number**', date_text: '^^redacted date^^', token_text: '*****').redact
|
79
80
|
# => '***** announced a merger with ***** that will happen on ^^redacted date^^ for **redacted number**. Please contact ***** at ***** or visit *****.'
|
80
81
|
```
|
@@ -62,7 +62,7 @@ module ConfidentialInfoRedactor
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def redact_dates(txt)
|
65
|
-
ConfidentialInfoRedactor::Date.new(string: txt, language: language).replace.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}.")
|
65
|
+
ConfidentialInfoRedactor::Date.new(string: txt, language: language).replace.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}.")
|
66
66
|
end
|
67
67
|
|
68
68
|
def redact_numbers(txt)
|
@@ -148,5 +148,11 @@ RSpec.describe ConfidentialInfoRedactor::Redactor do
|
|
148
148
|
text = 'Coca-Cola announced a merger with Pepsi that will happen on December 15th, 2020 for $200,000,000,000. Please contact John Smith at j.smith@example.com or visit http://www.super-fake-merger.com.'
|
149
149
|
expect(described_class.new(text: text, language: 'en', tokens: tokens, ignore_numbers: true).redact).to eq('<redacted> announced a merger with <redacted> that will happen on <redacted date> for $200,000,000,000. Please contact <redacted> at <redacted> or visit <redacted>.')
|
150
150
|
end
|
151
|
+
|
152
|
+
it 'redacts all confidential information from a text #005' do
|
153
|
+
tokens = ['Coca-Cola', 'Pepsi', 'John Smith']
|
154
|
+
text = 'Coca-Cola announced a merger with Pepsi that will happen on December 15th, 2020 for $200,000,000,000. Please contact John Smith at j.smith@example.com or visit http://www.super-fake-merger.com.'
|
155
|
+
expect(described_class.new(text: text, language: 'en', tokens: tokens, number_text: '**redacted number**', date_text: '^^redacted date^^', token_text: '*****').redact).to eq('***** announced a merger with ***** that will happen on ^^redacted date^^ for **redacted number**. Please contact ***** at ***** or visit *****.')
|
156
|
+
end
|
151
157
|
end
|
152
158
|
end
|