-2

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

3
  • Seems like you would need a parameter for the function that tells what type of string it is. And then a switch/if statement. Probably better to have separate functions. Commented Feb 21, 2024 at 3:03
  • also tried just adding a dummy param to signify what kind of string its matching for ,and just called the function twice based on what i was trying to match,would that work ? Commented Feb 21, 2024 at 12:32
  • A real parameter. An enum, string or int that denoted what type of data the string had in it. Commented Feb 21, 2024 at 13:49

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

okay ,much appreciated,will try it out
for further assistance, i would prefer to know the logic of your code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.