diff --git a/spacy/en/pos.pyx b/spacy/en/pos.pyx index fd6d468a9..5a19bbf27 100644 --- a/spacy/en/pos.pyx +++ b/spacy/en/pos.pyx @@ -265,6 +265,8 @@ cdef class EnPosTagger: Args: tokens (Tokens): The tokens to be tagged. """ + if tokens.length == 0: + return 0 cdef int i cdef atom_t[N_CONTEXT_FIELDS] context cdef const weight_t* scores diff --git a/spacy/syntax/parser.pyx b/spacy/syntax/parser.pyx index 33e4af179..061aee6df 100644 --- a/spacy/syntax/parser.pyx +++ b/spacy/syntax/parser.pyx @@ -72,6 +72,9 @@ cdef class GreedyParser: Transition guess uint64_t state_key + if tokens.length == 0: + return 0 + cdef atom_t[CONTEXT_SIZE] context cdef int n_feats cdef Pool mem = Pool()