Comparing 2 similar strings?

John Machin sjmachin at lexicon.net
Wed May 18 17:07:56 EDT 2005


On Wed, 18 May 2005 13:45:30 -0700, Don <donald.welch at NOSPAM.hp.com>
wrote:

>http://www.personal.psu.edu/staff/i/u/iua1/python/apse/

The above is broken, not meeting one of the elementary conditions for
a distance metric:

distance(a, b) == distance(b, a)

Quoting from its docs:
 |  Note: The definition of the goodness of an approximate match is
the 
 |  number of steps required to bring the string pattern to a form
that is 
 |  entirely contained in the string to which it is being matched.

Note: "entirely contained in", rather than "equal to". Now read on:


 | The mathing 
 |  is not commutative. The pattern that you instantiate the class
with will be 
 |  matched against the input. For example the word "funky" can be
made to 
 |  match the word "funnybone" with an edit distance of one. However,
using 
 |  "funnybone" as a pattern that will be  matched to "funky" the
distance 
 |  will become five.
 |  
 |  Example:
 |  
 |  >>> from Apse import Approx
 |  >>> a = Approx("funky")
 |  >>> a.dist("funnybone")
 |  1
 |  >>> a = Approx("funnybone")
 |  >>> a.dist("funky")
 |  5





More information about the Python-list mailing list