diff --git a/spacy/pipeline.pyx b/spacy/pipeline.pyx index faea20935..edc793158 100644 --- a/spacy/pipeline.pyx +++ b/spacy/pipeline.pyx @@ -482,7 +482,7 @@ class Tagger(Pipe): if lemma != 0 and lemma != doc.c[j].lex.orth: doc.c[j].lemma = lemma idx += 1 - if tensors is not None: + if tensors is not None and len(tensors): if isinstance(doc.tensor, numpy.ndarray) \ and not isinstance(tensors[i], numpy.ndarray): doc.extend_tensor(tensors[i].get()) diff --git a/spacy/syntax/nn_parser.pyx b/spacy/syntax/nn_parser.pyx index 21ee603a3..91e4b6852 100644 --- a/spacy/syntax/nn_parser.pyx +++ b/spacy/syntax/nn_parser.pyx @@ -217,6 +217,8 @@ cdef class Parser: def predict(self, docs, beam_width=1, beam_density=0.0, drop=0.): if isinstance(docs, Doc): docs = [docs] + if not any(len(doc) for doc in docs): + return self.moves.init_batch(docs) if beam_width < 2: return self.greedy_parse(docs, drop=drop) else: