This is probably not what you want, but since it's interesting, I thought I would bring it up. There is actually something produced about a decade ago called the Similarity Metric (see also Clustering by Compression). The idea is given
y we want to calculate the length of the shortest program that produces
x (modulo some fudge factors). If we normalize this appropriately, we get a good notion of relative similarity. However, this notion is defined in terms of Kolmogorov complexity which is not computable, so this doesn't actually produce a usable algorithm. We have to approximate it instead. This leads to the Normalized Compression Distance which is simply:
NCD(x,y) = (C(x++y) - min(C(x),C(y))/max(C(x),C(y))
x++y represents the concatenation of
y viewed as bit sequences. And, importantly,
C(x) represents the bit length of the compressed representation of
x for some (appropriately behaving) compression algorithm
C. Basically, if you take a compression algorithm, such as
gzip, you can simply compress each input and their concatenation and use the above formula to get a rational number between 0 and 1 indicating how "similar" they are. (You can then round that rational number to the nearest fixed point number for a given number of bits to get a fixed size output.) This assumes every bit is significant. It may well make sense to "normalize" the input (e.g. removing extraneous whitespace or low-pass filtering) to avoid spurious differences. Conceptually, this can be folded into the compression algorithm. This points out that this notion of similarity varies with the compression algorithm, though general-purpose compression algorithms are often adequate. Some tools to do this are here, though it would be easy to roll your own.
I suspect a real compressor will be "too good" at finding similarities for your purposes. That is, it will find similarity between things that you don't want to consider similar. That might be technically resolvable by a suitable choice of compressor, but using some other metric may make more sense than doing this.