[AccessD] "fuzzy logic" search

Stuart McLachlan stuart at lexacorp.com.pg
Wed Oct 22 17:17:43 CDT 2003


On 22 Oct 2003 at 9:26, John Colby wrote:

> Stuart,
> 
> Could you comment the code for me?  I have no idea what the hamming distance
> is trying to accomplish and don't wish to take a class to figure it out.
> Just a 1 paragraph overview at te top and a couple of line comments thrown
> in would be a great help.
> 

Sorry, I thought it was fairly obvious.

Hamming Distance is a measure of the "differentness" of two strings:
It is just a count  of the number of locations within a string  which 
are different. The function just checks whether the two strings are 
the same length and then steps through them comparing the character 
at each location.

I used a flag of -1 to indicate that the strings where a different 
length.
A perfect match  has a Hamming Distance of 0.
If one character has been mistyped, there will be a Hamming Distance 
of 1.  If two mistypes (including  a transposition of two digits) the 
Hamming Distance will be 2 etc.

I just check for a Hamming Distance of 1, or a distance of 2 where 
the checksum of the two strings is the same (an indication that they 
are likely to contain the same set of characters)

 
-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System 
Support.





More information about the AccessD mailing list