mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-13 13:17:06 +03:00
* Add __iter__ method to tokens
This commit is contained in:
parent
f07457a91f
commit
954c970415
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user