<jupyter_start><jupyter_text>Let's compare a vs. b<jupyter_code>fuzz.ratio(a,b)<jupyter_output><empty_output><jupyter_text>Now let's try a vs. c<jupyter_code>fuzz.ratio(a,c)<jupyter_output><empty_output><jupyter_text>Well that doesn't look right! What if we look at substrings?Let's find the longest word in the string then give more weight to those words. This assumes that longer words carry more "meaning"<jupyter_code>a = 'Department of Defense'
b = 'Defense Department'
c = 'Department of State'
d = 'Department of '
fuzz.partial_ratio(a,b)
fuzz.partial_ratio(a,c)
fuzz.partial_ratio(a,d)<jupyter_output><empty_output><jupyter_text>Not that either! What if we sort the words prior to looking at ratios?If we first order the words in each string (alphabetically) and then compare those words, do we see improvement?<jupyter_code>a = 'Department of Defense'
b = 'Defense Department'
c = 'Department of State'
d = 'Department of '
fuzz.token_sort_ratio(a,b)
fuzz.token_sort_ratio(a,c)<jupyter_output><empty_output><jupyter_text>Not bad....what if we look at the set intersection of words and compare the sets?<jupyter_code>a = 'Department of Defense'
b = 'Defense Department'
c = 'Department of State'
d = 'Department of '<jupyter_output><empty_output><jupyter_text>b is a total subset of a<jupyter_code>fuzz.token_set_ratio(a,b)<jupyter_output><empty_output><jupyter_text>c is a partial subset of a<jupyter_code>fuzz.token_set_ratio(a,c)<jupyter_output><empty_output><jupyter_text>d is also a total subset of a<jupyter_code>fuzz.token_set_ratio(a,d)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup