Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import numpy as np
  2. import sys
  3.  
  4. space = shingleSpace(sets)
  5. sortedSpace = sorted(space)
  6.  
  7. def computeSignature(space, hashes, sets):
  8. """
  9. This function will create the minhash signature matrix from our sets s1-s4
  10. using the list of hashfunction hashes and the shingleSpace space
  11. :param space: The ShingleSpace set
  12. :param hashes: The list of hashes
  13. :param sets: The list of ShingleSets
  14. :return: The MinHashSignature
  15. """
  16.  
  17. result = np.full((len(hashes),len(sets)), sys.maxsize)
  18.  
  19. # Start coding here!
  20. sSpace = sorted(space)
  21.  
  22. for i in range(len(sSpace)):
  23. shingle = sSpace[i]
  24. for shingleSetIndex in range(len(sets)):
  25. shingleSet = sets[shingleSetIndex]
  26. if shingle in shingleSet:
  27. for hashIndex in range(len(hashes)):
  28. hashObj = hashes[hashIndex]
  29. result[hashIndex][shingleSetIndex] = min(hashObj.hashf(i, len(sSpace)),result[hashIndex][shingleSetIndex])
  30.  
  31.  
  32. return result
  33.  
  34. computeSignature(space, hashes, sets)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement