Fuzzy matching algorithm adapted from one by Ed Kubaitis. Based on an original idea by Jonathan Partington.