Procedure Analyzer is a Python based service for detecting PII entities in text during analysis.
It runs a set of different PII recognizers, each one in charge of detecting one or more PII entities
using different mechanisms.
It comes with a set of predefined recognizers, but it can be easily extended with other custom recognizers
as well.
Predefined and custom recognizers can leverage regex named entity recognition, also known as NER,
and other types of logic, to detect PII in unstructured data.
So here is the pip install Presidio analyzer.
And here is the spacey Encore Web LG as the English language processing model for detecting the APIs.
Right?
Let's go ahead and install and download them.
The following code sample will be responsible for setting up the analyzer engine, which would load
the NLP model by default, and other PII recognizers which goes in here.
Right.
And then we'll call the analyzer to analyze the results for the phone number.
In this case we are setting up the text to anonymize as the text that we want to analyze.
And the entity that we want to detect is the phone number.
Right.
So here is the code for it.
Let's go ahead and run this.
Um, I missed the part where I had to import the, uh.
The class here.
Analyzer engine.
Right.
Uh, which also will in future require the pattern recognizer, which is a custom pattern that we will
create for detecting our custom entities.
Right.
And now I'll go ahead and run this.
Right.
So now if you notice here it did detect phone number which starts from the um, uh, 46 as the count
here until 58.
Right.
And the score is 0.75, which means that the, uh, the confidence level for, Saying that this particular
entity is a phone number is very high, right?
So that is how we use the analyzer engine to to analyze the text and uh, find the entity phone number.
Right.
Now let's go ahead and understand how the, the entire uh, class diagram for Procedure Analyzer is,
is set up.
So here is the, um, the class diagram for Procedure Analyzer.
Here is the analyzer engine that we just went through to understand the, uh, understand and detect
the, uh, the phone number.
Uh, but if you notice here it has other components as well.
In the, in the, in the hierarchy.
Right.
So here on the left hand side we have entity recognizer.
Entity recognizer is an object that is responsible for detecting entities in text.
It can be rule based recognizer machine learning model or a combination of both.
Right.
Then we have here uh, the recognizer registry.
Uh, it is a registry that contains all the entity recognizers that are available in the Presidio.
The analyzer engine uses the registry to detect entities in the text.
Right.
Then here we have the NLP engine, which is an object that holds the NLP model that is used by the analyzer
engine.
You can use a variety of different NLP engines to, uh, to detect the, uh, the entities in the text.
You can use Spacy, transformer or Stanza NLP engines to, uh, to run the detection uh, in the text.
And then here we have context aware enhancer.
It's a module that enhances the detection of entities by using context of the text.
One particular class that is not covered here is the pattern recognizer.
Uh, it is a type of entity recognizer that uses regular expressions to detect entities in the text.
Um, we'll cover that as part of another video with hands on activity.
But here is the, uh, high level understanding of how Presidio Analyzer works.
Thank you.
I'll see you in the next.