Skip to content

Instantly share code, notes, and snippets.

@talfco
Created March 17, 2019 08:29
Show Gist options
  • Save talfco/3f91542cdfc800efd4971f40441e2816 to your computer and use it in GitHub Desktop.
Save talfco/3f91542cdfc800efd4971f40441e2816 to your computer and use it in GitHub Desktop.
def match_name(self, name_tuple):
match_list = []
combinations = self.generate_combinations(name_tuple)
for comb_tuple in combinations:
concat_name = self.generate_normalized_name(comb_tuple)
metaphone_tuple = doublemetaphone(concat_name)
if metaphone_tuple[0] in self.__lookup_dict[0]:
match_list.append((concat_name, self.__lookup_dict[0][metaphone_tuple[0]]))
# Iterate through all matches and check for single result tuples
# Ensure that the singe result tuples are pointing to the same id
# If not or no single result tuple exists, return 'None'
unique_id = None
for match_tuple in match_list:
if len(match_tuple[1]) == 1:
if unique_id is not None:
if unique_id != match_tuple[1][0]:
unique_id = None
break
else:
unique_id = match_tuple[1][0]
return unique_id, match_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment