예제 #1
0
 def load_recognizers(self, path):
     #   TODO: Change the code to dynamic loading -
     # Task #598:  Support loading of the pre-defined recognizers
     # from the given path.
     self.recognizers.extend([CreditCardRecognizer(),
                              UsPhoneRecognizer(),
                              DomainRecognizer()])
예제 #2
0
def recognizers():
    rec_map = {
        "IP_ADDRESS": IpRecognizer(),
        "US_SSN": UsSsnRecognizer(),
        "PHONE_NUMBER": UsPhoneRecognizer(),
        "US_ITIN": UsItinRecognizer(),
        "US_DRIVER_LICENSE": UsLicenseRecognizer(),
        "US_BANK_NUMBER": UsBankRecognizer(),
        "US_PASSPORT": UsPassportRecognizer(),
        "FIN": SgFinRecognizer(),
    }
    return rec_map
예제 #3
0
 def load_predefined_recognizers(self):
     #   TODO: Change the code to dynamic loading -
     # Task #598:  Support loading of the pre-defined recognizers
     # from the given path.
     # Currently this is not integrated into the init method to speed up
     # loading time if these are not actually needed (SpaCy for example) is
     # time consuming to load
     self.recognizers.extend([
         CreditCardRecognizer(),
         CryptoRecognizer(), DomainRecognizer(),
         EmailRecognizer(), IbanRecognizer(),
         IpRecognizer(), NhsRecognizer(),
         UsBankRecognizer(), UsLicenseRecognizer(),
         UsItinRecognizer(), UsPassportRecognizer(),
         UsPhoneRecognizer(), UsSsnRecognizer(),
         SpacyRecognizer(), SgFinRecognizer()])
예제 #4
0
from unittest import TestCase

import os
import pytest

from presidio_analyzer import PatternRecognizer, Pattern
from presidio_analyzer.predefined_recognizers import CreditCardRecognizer, \
    UsPhoneRecognizer, DomainRecognizer, UsItinRecognizer, \
    UsLicenseRecognizer, UsBankRecognizer, UsPassportRecognizer, \
    IpRecognizer, UsSsnRecognizer, SgFinRecognizer 
from presidio_analyzer.nlp_engine import NlpArtifacts
from tests import TESTS_NLP_ENGINE

ip_recognizer = IpRecognizer()
us_ssn_recognizer = UsSsnRecognizer()
phone_recognizer = UsPhoneRecognizer()
us_itin_recognizer = UsItinRecognizer()
us_license_recognizer = UsLicenseRecognizer()
us_bank_recognizer = UsBankRecognizer()
us_passport_recognizer = UsPassportRecognizer()
sg_fin_recognizer = SgFinRecognizer()

@pytest.fixture(scope="class")
def sentences_with_context(request):
    """ Loads up a group of sentences with relevant context words
    """

    path = os.path.dirname(__file__) + '/data/context_sentences_tests.txt'
    f = open(path, "r")
    if not f.mode == 'r':
        return []
def recognizer():
    return UsPhoneRecognizer()
 def load_predefined_recognizers(self, languages=None, nlp_engine=None):
     self.recognizers.extend(
         [CreditCardRecognizer(),
          UsPhoneRecognizer(),
          DomainRecognizer()])