* Add __iter__ method to tokens

This commit is contained in:
Matthew Honnibal 2014-11-04 01:07:08 +11:00
parent f07457a91f
commit 954c970415
1 changed files with 4 additions and 0 deletions

View File

@ -59,6 +59,10 @@ cdef class Tokens:
bounds_check(i, self.length, PADDING)
return Token(self._string_store, i, self.idx[i], self.pos[i], self.lex[i][0])
def __iter__(self):
for i in range(self.length):
yield self[i]
def __len__(self):
return self.length