Ejemplo n.º 1
0
def simple_kark_sort(s):
  n = len(s)
  SA = [0 for _ in s]
  s += unichr(1) * 3
  alpha = sorted(set(s))
  tools.kark_sort(s, SA, n, alpha)
  return SA
Ejemplo n.º 2
0
  def step1_sort_suffix(self) :
    n = len(self.global_suffix)
    init = [-1]*n
    self.idxString = array('i', init)
    self.idxPos = array('i', init)
    self.endAt = array('i', init)
    
    k = idx = 0
    for w in self.array_str :
      len_w = len(w)
      last = k + len_w
      for p in xrange(len_w) :
        self.idxString[k] = idx
        self.idxPos[k] = p
        self.endAt[k] = last
        k += 1
      idx += 1
      k += 1

    res = array('i',[0]*(n+3))
    kark_sort(array('i',self.global_suffix+[0,0,0]), res, n, self.len_alphabet)
    self.res = res[:n]
Ejemplo n.º 3
0
    def step1_sort_suffix(self):
        n = len(self.global_suffix)
        init = [-1] * n
        self.idxString = array('i', init)
        self.idxPos = array('i', init)
        self.endAt = array('i', init)

        k = idx = 0
        for w in self.array_str:
            len_w = len(w)
            last = k + len_w
            for p in xrange(len_w):
                self.idxString[k] = idx
                self.idxPos[k] = p
                self.endAt[k] = last
                k += 1
            idx += 1
            k += 1

        res = array('i', [0] * (n + 3))
        kark_sort(array('i', self.global_suffix + [0, 0, 0]), res, n,
                  self.len_alphabet)
        self.res = res[:n]