From a1b05048d0da75f02b64a9b4719ce40137551234 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 29 Jun 2018 16:05:40 +0200 Subject: [PATCH] Fix tagger when doc is empty --- spacy/pipeline.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacy/pipeline.pyx b/spacy/pipeline.pyx index 339bf4f1c..faea20935 100644 --- a/spacy/pipeline.pyx +++ b/spacy/pipeline.pyx @@ -450,7 +450,9 @@ class Tagger(Pipe): if not any(len(doc) for doc in docs): # Handle case where there are no tokens in any docs. n_labels = len(self.labels) - return [self.model.ops.allocate((0, n_labels)) for doc in docs] + guesses = [self.model.ops.allocate((0, n_labels)) for doc in docs] + tokvecs = self.model.ops.allocate((0, self.model.tok2vec.nO)) + return guesses, tokvecs tokvecs = self.model.tok2vec(docs) scores = self.model.softmax(tokvecs) guesses = []