Last active
February 4, 2020 18:52
-
-
Save Sirsirious/15fccfd6112e6360b6cd38b6d9e71023 to your computer and use it in GitHub Desktop.
How to make our DummySentencizer iterable.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __iter__(self): | |
return self | |
def __next__(self): | |
if self._index < len(self.sentences): | |
result = self.sentences[self._index] | |
self._index+=1 | |
return result | |
raise StopIteration |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment