Skip to content

Instantly share code, notes, and snippets.

@srsani
Created August 22, 2023 12:50
Show Gist options
  • Save srsani/76595766f721a8a392d3ace6df11542e to your computer and use it in GitHub Desktop.
Save srsani/76595766f721a8a392d3ace6df11542e to your computer and use it in GitHub Desktop.
def dict_distance (dict1:dict,
dict2:dict) -> float:
distance_list = []
character_length = []
for key, value in dict1.items():
distance_list.append(edit_distance(dict1[key].strip(),
dict2[key].strip()))
if len(dict1[key]) > len(dict2[key]):
character_length.append((len(dict1[key])))
if len(dict2[key]) >= len(dict1[key]):
character_length.append((len(dict2[key])))
accuracy = 100 - sum(distance_list)/(sum(character_length))*100
return accuracy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment