YauhenMardan

Untitled

Apr 30th, 2021
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1.  
  2. # def constructSuffixArray(convertedTextSplit, wordCount):
  3. # suffixes = [(convertedTextSplit[i:i + wordCount], i) for i in range(len(convertedTextSplit))]
  4. # suffixes.sort(key=lambda s: s[0])
  5. # return [s[1] for s in suffixes]
  6. # def sort_bucket(convertedTextSplit, bucket, order, wordCount):
  7. # d = defaultdict(list)
  8. # for i in bucket:
  9. # key = ''.join([str(ss) for ss in convertedTextSplit[i:i+order]])
  10. # d[key].append(i)
  11. # result = []
  12. # for k,v in sorted(d.items()):
  13. # if len(v) > 1:
  14. # result += sort_bucket(convertedTextSplit, v, order*2,wordCount)
  15. # else:
  16. # result.append(v[0])
  17. # return result
  18.  
  19. # def constructSuffixArray(convertedTextSplit, wordCount):
  20. # return sort_bucket(convertedTextSplit, (i for i in range(len(convertedTextSplit))), 1, wordCount)
Advertisement
Add Comment
Please, Sign In to add comment