Source code for ads.type_discovery.phone_number_detector
#!/usr/bin/env python# -*- coding: utf-8; -*-# Copyright (c) 2020, 2022 Oracle and/or its affiliates.# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/from__future__importprint_function,absolute_import,divisionimportreimportpandasaspdfrompandas.api.typesimportis_string_dtypefromads.type_discoveryimportloggerfromads.type_discovery.abstract_detectorimportAbstractTypeDiscoveryDetectorfromads.type_discovery.typed_featureimportPhoneNumberTypedFeature
if__name__=="__main__":dd=PhoneNumberDetector()# test the postive case:test_series_1=["408-456-7890","(123) 456-7890","650 456 7890","650.456.7890","+91 (123) 456-7890",]print(dd.discover("test_series_1",pd.Series(test_series_1)))# test the negative casetest_series_2=["1234567890","1234567890","123456890","1234567890"]print(dd.discover("test_series_2",pd.Series(test_series_2)))test_series_3=["1-640-124-5367","1-573-916-4412"]print(dd.discover("test_series_3",pd.Series(test_series_3)))