Hello everyone!
In this video we will cover the component Anonymizer, which will iterate over the Presidio Analyzer
results and provide anonymization capabilities for the identified text.
The Anonymizer provides five different types of features or capabilities, that is, replace, redact,
mask, hash, and encrypt.
The default is to replace the text.
So in this particular exercise that will go through we will set up the Anonymizer engine, will create
an Anonymizer request.
And then we will anonymize the text.
Right.
So let's go ahead and first start the very first step.
So now this is done installing the default packages that we need.
Let's go ahead and uh first analyze the uh the text for that.
I'll quickly import the desired classes.
All right.
So now first analyzer import.
Analyzer engine.
And here I will go ahead and.
Add the text that we want to add anonymize.
I will use the same text that we have used in our previous videos which is.
His name is Mr. Jones and his phone number is this right?
Quickly.
Analyzer.
Uh.
Instantiate it.
And then.
Get the results.
Thank you.
Right.
So we are going to analyze phone number that we have done it in our previous video.
I missed the print statement here.
Right.
Let me execute this one more time.
Okay okay okay.
All right.
Great.
So now let's go ahead and run the Anonymizer engine on the analyzer results.
For that, I'll have to import.
The classes anonymizer engine and the operator config.
Now let me go ahead and.
Initialize the Anonymizer engine.
Now let's anonymize the the the results.
So for that.
I'll say anonymized results would be the variable.
And then.
Anonymizer dot anonymize.
Right.
And then I'll go ahead and, um, add the text that we want to anonymize.
Right.
Use the analyzer results from here.
And then, uh, use the operators.
That is going to be a custom operator here, which is phone number.
So here I added the operator here as phone number.
And the configuration here is that I want to mask the, uh, text with the character as Asterix and
the number of characters to mask is 12 and mask.
The entire text is from start to the end of it, right?
And now let's go ahead and print the results.
And then let's go ahead and run this.
It was pretty quick.
And if you notice here that this is the text that his name is Mr. Jones and his phone number is the
masked up or anonymized, uh, strings.
And here is the detail about this, that it starts at 4 to 6 and Z 58.
This is the phone number and this is the text.
And the operator is masked.
All right.
Um, this is the anonymized component that we went through from the Presidio framework.
Thank you.