From 396dd60b3a9ef62f27bf406aff82b167ed8c63a3 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 20 Jun 2020 21:49:15 +0200 Subject: [PATCH] Fix Corpus --- spacy/gold/corpus_docbin.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spacy/gold/corpus_docbin.py b/spacy/gold/corpus_docbin.py index 8ee1e9a6c..750217c8c 100644 --- a/spacy/gold/corpus_docbin.py +++ b/spacy/gold/corpus_docbin.py @@ -68,10 +68,12 @@ class Corpus: i += 1 return n - def train_dataset(self, nlp, **kwargs): + def train_dataset(self, nlp, shuffle=True, **kwargs): ref_docs = self.read_docbin(nlp.vocab, self.walk_corpus(self.train_loc)) - examples = list(self.make_examples(nlp, ref_docs, **kwargs)) - random.shuffle(examples) + examples = self.make_examples(nlp, ref_docs, **kwargs) + if shuffle: + examples = list(examples) + random.shuffle(examples) yield from examples def dev_dataset(self, nlp):