Coverage for presidio_analyzer / predefined_recognizers / country_specific / us / us_bank_recognizer.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-03-29 09:03 +0000

1from typing import List, Optional 

2 

3from presidio_analyzer import Pattern, PatternRecognizer 

4 

5 

6class UsBankRecognizer(PatternRecognizer): 

7 """ 

8 Recognizes US bank number using regex. 

9 

10 :param patterns: List of patterns to be used by this recognizer 

11 :param context: List of context words to increase confidence in detection 

12 :param supported_language: Language this recognizer supports 

13 :param supported_entity: The entity this recognizer can detect 

14 """ 

15 

16 PATTERNS = [ 

17 Pattern( 

18 "Bank Account (weak)", 

19 r"\b[0-9]{8,17}\b", 

20 0.05, 

21 ), 

22 ] 

23 

24 CONTEXT = [ 

25 # Task #603: Support keyphrases: change to "checking account" 

26 # as part of keyphrase change 

27 "check", 

28 "account", 

29 "account#", 

30 "acct", 

31 "bank", 

32 "save", 

33 "debit", 

34 ] 

35 

36 def __init__( 

37 self, 

38 patterns: Optional[List[Pattern]] = None, 

39 context: Optional[List[str]] = None, 

40 supported_language: str = "en", 

41 supported_entity: str = "US_BANK_NUMBER", 

42 name: Optional[str] = None, 

43 ): 

44 patterns = patterns if patterns else self.PATTERNS 

45 context = context if context else self.CONTEXT 

46 super().__init__( 

47 supported_entity=supported_entity, 

48 patterns=patterns, 

49 context=context, 

50 supported_language=supported_language, 

51 name=name, 

52 )