Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def iter(self, string, start=None, end=None):
- start = start if start is not None else 0
- end = end if end is not None else len(string)
- state = self.root
- for index, c in enumerate(string[start:end]):
- while c not in state.children:
- state = state.fail
- state = state.children.get(c, self.root)
- tmp = state
- output = []
- while tmp is not nil and tmp.output is not nil:
- output.append(tmp.output)
- tmp = tmp.fail
- if output:
- yield (index + start, output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement