Skip to content

Instantly share code, notes, and snippets.

View scotta's full-sized avatar

Andrew Scott scotta

  • Geelong, Australia
View GitHub Profile
@scotta
scotta / strikeamatch.py
Last active August 25, 2021 21:13
Python implementation of the "Strike a match" algorithm presented in the article http://www.catalysoft.com/articles/StrikeAMatch.html
"""Implementation of the "Strike a match" algorithm presented in the article
http://www.catalysoft.com/articles/StrikeAMatch.html by Simon White.
Excerpt from the above URL: The similarity between two strings s1 and s2 is
twice the number of character pairs that are common to both strings divided by
the sum of the number of character pairs in the two strings. Note that the
formula rates completely dissimilar strings with a similarity value of 0, since
the size of the letter-pair intersection in the numerator of the fraction will
be zero. On the other hand, if you compare a (non-empty) string to itself, then
the similarity is 1.