3 ms·
I was somewhere with no internet connection and an old laptop with Golang on it. I needed a string similarity function. Remembering vaguely hearing there was so
by davidwritesbugs 5y ago
I was somewhere with no internet connection and an old laptop with Golang on it. I needed a string similarity function. Remembering vaguely hearing there was some kind of 'distance' algorithm to do this I hit on the idea of treating the digits a multiple dimensions and calculating the pythagorean distance. If you fancy a laugh I suggest you try this approach, the numbers get astonishly huge very quickly. I started taking the logs of numbers and even then getting overflow errors. I wished I'd seen this!
- eru 5y agoI guess Go's arbitrary precision numbers are a bit of a pain to work with.
- snovv_crash 5y agoThe key insight you missed is that it doesn't matter how far away in the ASCII table a letter is. Just assigning a 0 distance if equal or a 1 if different, per character, would have made things a lot easier.