Example #1
0
    def between(a, b):
        """Returns the normalized edit distance between two strings.

        This also strips out stopwords and punctuation from either string,
        and returns the maximum score with or without them.

        >>> NormalizedEditDistanceStopwords.between("abc", "abc")
        1.0
        >>> NormalizedEditDistanceStopwords.between("Boeing Corporation, "Boeing")
        1.0
        >>> NormalizedEditDistanceStopwords.between("abcd", "abef")
        0.5
        """

        a_processed = strip_stopwords(a)
        b_processed = strip_stopwords(b)

        return max(NormalizedEditDistance.between(a, b_processed),
                   NormalizedEditDistance.between(a_processed, b),
                   NormalizedEditDistance.between(a, b),
                   NormalizedEditDistance.between(a_processed, b_processed))
Example #2
0
 def score(query, profile, data=None):
     return [NormalizedEditDistance.between(query, profile.display_name)]
Example #3
0
 def score(query, profile, data=None):
     return [NormalizedEditDistance.between(query, profile.handle)]