How to use the presidio-analyzer.analyzer.predefined_recognizers.spacy_recognizer.SpacyRecognizer.__check_label function in presidio-analyzer

To help you get started, we’ve selected a few presidio-analyzer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / presidio / presidio-analyzer / analyzer / predefined_recognizers / spacy_recognizer.py View on Github external
def analyze(self, text, entities, nlp_artifacts=None):
        results = []
        if not nlp_artifacts:
            self.logger.warning(
                "Skipping SpaCy, nlp artifacts not provided...")
            return results

        ner_entities = nlp_artifacts.entities

        for entity in entities:
            if entity in self.supported_entities:
                for ent in ner_entities:
                    if SpacyRecognizer.__check_label(entity, ent.label_):
                        explanation = SpacyRecognizer.build_spacy_explanation(
                            self.__class__.__name__,
                            NER_STRENGTH,
                            ent.label_)
                        spacy_result = RecognizerResult(
                            entity, ent.start_char,
                            ent.end_char, NER_STRENGTH, explanation)
                        results.append(spacy_result)

        return results

presidio-analyzer

Presidio Analyzer package

MIT
Latest version published 4 months ago

Package Health Score

94 / 100
Full package analysis

Similar packages