def string_suggestions(string, vocabulary, cutoff=0.6, maxnum=3):
 return [tup[1] for tup in sorted([(string_similarity(string, sugg), sugg) for sugg in vocabulary], key=(lambda tup: tup[0]), reverse=True) if (tup[0] >= cutoff)][:maxnum]

def string_suggestions ( string , vocabulary , cutoff = 0.6 , maxnum = 3 ) : return [ tup [ 1 ] for tup in sorted ( [ ( string_similarity ( string , sugg ) , sugg ) for sugg in vocabulary ] , key = ( lambda tup : tup [ 0 ] ) , reverse = True ) if ( tup [ 0 ] >= cutoff ) ] [ : maxnum ]
given a string and a vocabulary .