* Add __iter__ method to tokens

This commit is contained in:
Matthew Honnibal 2014-11-04 01:07:08 +11:00
parent f07457a91f
commit 954c970415

View File

@ -59,6 +59,10 @@ cdef class Tokens:
bounds_check(i, self.length, PADDING) bounds_check(i, self.length, PADDING)
return Token(self._string_store, i, self.idx[i], self.pos[i], self.lex[i][0]) 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): def __len__(self):
return self.length return self.length