I have a method that compares a person's name with other person's details. However, it may fail in scenarios where the middle name is included in the first name or other similar combinations.
I'm exploring potential solutions and would like to know if applying fuzzy logic is an appropriate approach, or if there's a simpler and more effective solution available. Thanks.
private boolean compareString(String compareFirstName, String compareMiddleName, String compareLastName) {
return firstName.equalsIgnoreCase(compareFirstName) &&
middleName.equalsIgnoreCase(compareMiddleName) &&
lastName.equalsIgnoreCase(compareLastName);
}
IMHO, you may utilize the Apache Commons Text library for fuzzy string matching. The trick here is to calculate the matching score between the string you compare and use it to benchmark the similarity.
You may adjust the threshold according to your scenario. Hope this might give you an idea to kick start.