Last active
February 20, 2021 10:54
-
-
Save vmarkovtsev/f9291a712d7d3a4564c1bc878ab77a5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fuzzywuzzy import fuzz | |
def distance_ratio(s1: str, s2: str) -> int: | |
return 100 - fuzz.ratio(s1, s2) | |
def distance_join_ratio(s1: str, s2: str) -> int: | |
return 100 - fuzz.ratio(s1.replace(" ", ""), s2.replace(" ", "")) | |
def distance_sort_ratio(s1: str, s2: str) -> int: | |
return 100 - fuzz.token_sort_ratio(s1, s2) | |
def distance_set_ratio(s1: str, s2: str) -> int: | |
return 100 - fuzz.token_set_ratio(s1, s2) | |
def distance_max_ratio(s1: str, s2: str) -> int: | |
return min(distance_set_ratio(s1, s2), distance_ratio_join(s1, s2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment