Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pii_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ def create_analyzer():
patterns=[student_id_pattern])
registry.add_recognizer(student_id_recognizer)

american_phone_number_pattern = Pattern(name='american_phone_number',
regex=r'(\b)*1(-|.)?(\d{3}|\(\d{3}\))(-|.)?\d{3}(-|.)?\d{4}(\b)*',
score=0.85)
american_phone_number_recognizer = PatternRecognizer(supported_entity='AMERICAN_PHONE_NUMBER',
patterns=[american_phone_number_pattern])
registry.add_recognizer(american_phone_number_recognizer)


# Create a pattern to detect fourteen digit phone numbers
international_pn_pattern = Pattern(name='international_pn',
regex=r'^\d{3}-\d{3}-\d{4}-\d{4}',
Expand Down
4 changes: 2 additions & 2 deletions test_pii_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def test_base_supported_entities(self):
'AU_ACN',
'ORGANIZATION',
'STUDENT_ID',
'USERNAME'
]
'USERNAME',
'AMERICAN_PHONE_NUMBER']
for entity in supported_entities:
self.assertIn(entity, results)

Expand Down
29 changes: 28 additions & 1 deletion test_team_superior_coders.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TestSuperiorCoders(unittest.TestCase):
def test_aggie_pride(self):
"""Test to make sure the Aggie Pride function works"""
self.assertEqual('Aggie Pride - Worldwide', show_aggie_pride())

def test_political_standings(self):
""" Test to make sure political standing is detected"""
#positive testcase
Expand Down Expand Up @@ -36,7 +36,34 @@ def test_student_id_detect(self):
print(result)
self.assertNotIn('STUDENT_ID', str(result))

def test_american_phone_number_detect(self):
"""Test to ensure an American Phone Number is detected"""

#positive test case
results = analyze_text('My phone number is 1-(199)-555-9461')
print(results)
self.assertIn('AMERICAN_PHONE_NUMBER', str(results))

#positive test case
results = analyze_text('My phone number is 1.121.555.2962')
print(results)
self.assertIn('AMERICAN_PHONE_NUMBER', str(results))

#positive test case
results = analyze_text('My phone number is 11215552962')
print(results)
self.assertIn('AMERICAN_PHONE_NUMBER', str(results))

#Test to ensure an American Phone Number is not detected
#negetive test case
results = analyze_text('My phone number is -120-555-9461')
print(results)
self.assertNotIn('AMERICAN_PHONE_NUMBER', str(results))

#negetive test case
results = analyze_text('My phone number is 555-9461')
print(results)
self.assertNotIn('AMERICAN_PHONE_NUMBER', str(results))

def test_passport_number_detect(self):
"""Test to show if a passport number is detected"""
Expand Down