Make pipeline work on empty docs

This commit is contained in:
Matthew Honnibal 2018-06-29 19:21:38 +02:00
parent d0f9f13543
commit 01ace9734d
2 changed files with 3 additions and 1 deletions

View File

@ -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())

View File

@ -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: