From a4d2b0c293a2fc733e2ab7561a5825f8daf21420 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 29 Jun 2018 13:44:25 +0200 Subject: [PATCH] Fix bug when docs are empty --- spacy/pipeline.pyx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spacy/pipeline.pyx b/spacy/pipeline.pyx index e913b2647..d43e6990c 100644 --- a/spacy/pipeline.pyx +++ b/spacy/pipeline.pyx @@ -447,6 +447,9 @@ class Tagger(Pipe): yield from docs def predict(self, docs): + if not any(len(doc) for doc in docs): + # Handle case where there are no tokens in any docs. + return [self.model.ops.allocate((0, self.model.nO) for doc in docs] tokvecs = self.model.tok2vec(docs) scores = self.model.softmax(tokvecs) guesses = []