Created
August 6, 2017 11:07
-
-
Save gideonite/38f1148d27f685414dc0f32e43a1be27 to your computer and use it in GitHub Desktop.
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
import itertools | |
from spacy.en import English | |
def gen_items(): | |
print("Yield 0") | |
yield (0, 'Text 0') | |
print("Yield 1") | |
yield (1, 'Text 1') | |
print("Yield 2") | |
yield (2, 'Text 2') | |
nlp = English() | |
gen1, gen2 = itertools.tee(gen_items()) | |
ids = (id_ for (id_, text) in gen1) | |
texts = (text for (id_, text) in gen2) | |
docs = nlp.pipe(texts) | |
for id_, doc in itertools.izip(ids, docs): | |
print(id_, doc.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
taken from here: explosion/spaCy#172 (comment)