Fix bug when docs are empty

This commit is contained in:
Matthew Honnibal 2018-06-29 13:44:25 +02:00
parent c83fccfe2a
commit a4d2b0c293
1 changed files with 3 additions and 0 deletions

View File

@ -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 = []