Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1.  def iter(self, string, start=None, end=None):
  2.   start = start if start is not None else 0
  3.   end = end if end is not None else len(string)
  4.  
  5.   state = self.root
  6.   for index, c in enumerate(string[start:end]):
  7.    while c not in state.children:
  8.     state = state.fail
  9.  
  10.    state = state.children.get(c, self.root)
  11.  
  12.    tmp = state
  13.    output = []
  14.    while tmp is not nil and tmp.output is not nil:
  15.     output.append(tmp.output)
  16.     tmp = tmp.fail
  17.  
  18.    if output:
  19.     yield (index + start, output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement