joshaven/string_score — Issue #15: The result isn't a proper distance
Author: per-erik
Created: 2011-11-05 02:08:05+00:00
State: open

"Hello World".score("hello")
is not equal to
"hello".score("Hello World")
and thus the result isn't symmetric (a nice property if one wants to start meassure string edit distances).

This is somewhat in connection to issue #10. (This algorithm offers fast execution while giving up on some mathematical properties that some might find nice to have.)

Note that the particular test case above works "as expected" if one uses a fuzziness of 1. That isn't a solution though since it would yield strange results for things like "foo".score("Hello World", 1).

Also, it would be nice if two equal strings gave the result 0 and two completely different strings gave the result 1. Again, to satisfy the distance property. (If the distance between NY and London is 0 then NY and London are the same location. If the distance between the strings "foo" and "bar" is 0, then they are the same strings.)

Finally, I have not yet tested if it would satisfy the triangle inequality (a.score(b) + b.score(c) >= a.score(c) or, if you go from location a to location b and then from b to c, you must have walked further than or equal to the distance from a to c), but my guess is not. This too is needed to be a proper meassurement of distance.

On the other hand, you never set out to create an algorithm to meassure string distances, only to score strings.

PS. I love the project and it fits perfectly for what I'm about to do. Just writing this to explain why people might ask what this solution has to offer over things like the Levenshtein Distance or Hamming Distance and to document to other users that some things will not be possible with this solution. For the interested, this would likely be an algorithm producing an ordinal scale (ranking scale) so you can always compare two results but you can't do basic arithmetic on it. See http://en.wikipedia.org/wiki/Level_of_measurement for examples of what this implies.