-
-
Save reynoldsm88/9ebb85863cb6b06699b5a00e3b91ba38 to your computer and use it in GitHub Desktop.
Computing shingleprints for a document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def min_max_hashes(text, window=60): | |
hashes = [murmurhash(text[i:i+window]) for i in range(len(text)-window+1)] | |
return [min(hashes), max(hashes)] | |
def shingleprints(text): | |
min1, max1 = min_max_hashes(text[0:len(text)/2]) | |
min2, max2 = min_max_hashes(text[len(text)/2:]) | |
# combine pairs, using your favorite hash-value combiner | |
return [hash_combine(min1, min2), | |
hash_combine(min1, max2), | |
hash_combine(max1, min2), | |
hash_combine(max1, max2)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment