I'm looking for an algorithm which can generate a short (fx 16 chars (not important) hashcode/digest from a longer string.
The main requirement is that strings which is almost identical should result in the same digest.
Fx 2 almost identical mail:
Hi Martin. Here are some ... spam for you. Regards XYZ.
=> AAAA AAAA AAAA AAAA
Hi Bo. Here are some ... spam for you. Regards EFG.
=> AAAA AAAA AAAA AAAA
returns the same diges (or almost the same), where as a different mail:
Hello Finn. This is a test mail.
=> CCCC CCCC CCCC CCCC
will return a different digest.
This algorithm would be part of a spam filter. The filter will remember digests from mails which it is certain is spam. If the same digest shows up in mails where it is in doubt, the identical digest will cause the filter to increase the spamscore.
I know about Levenshtein, but it requires me to know the strings up front. In this situation i do not have this information. I could have this information, but that would require the filter for store all spam e-mail and check against each one, which would be a very slow process.
Maybe some loose compression algorithm coupled with a calc of the Levenshtein distance between the two could work.
Any pointers appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…