Incorporating Phone Number Matching into Existing String based Name Matching Function

47 views Asked by At

I have a Python function, match_strings, which is designed to match names from two different data sources. Here is the function definition:

python

def match_strings(strings1, strings2, ngram_n=2, threshold=0.3):

# Function logic goes here

pass

Now, I need to extend this function to also support matching phone numbers from the same data sources. I'm wondering whether it's better to create a separate function for phone number matching or incorporate it into the existing match_strings function.

I am considering:

Phone number matching may require different logic or processing compared to string matching. I'm considering using regular expressions (regex) to identify and match phone numbers. But I want the existing function to be flexible enough to handle different types of string as right now it is equipped to handle names(which is a bit more complex as opposed to phone numbers).and also important to note:id have to use different values of thresholds in case i have to match phone ,so the single function call may not work

Should I create a separate function for phone number matching, or is it feasible to incorporate it into the existing match_strings function? If so, how would I go about doing this effectively?

I appreciate any insights or suggestions on the best approach to implement phone number matching within the context of my existing string matching function

1

There are 1 answers

2
Manoj Kumar J On

you can use the same logic, but vary the threshold value and set it to 1, i am assuming as phone number needs to be matched with 100% accuracy unlike in the case of names and maybe add a dummy parameter - match_type = 'Name/Phone', which you can vary based on the function call you making based on what you are matching