diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index 661a14153..e1d90e921 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -240,7 +240,16 @@ cdef class Doc: self.c[i].ent_iob = 0 cdef attr_t ent_type cdef int start, end - for ent_type, start, end in ents: + for ent_info in ents: + if isinstance(ent_info, Span): + ent_id = ent_info.ent_id + ent_type = ent_info.label + start = ent_info.start + end = ent_info.end + elif len(ent_info) == 3: + ent_type, start, end = ent_info + else: + ent_id, ent_type, start, end = ent_info if ent_type is None or ent_type < 0: # Mark as O for i in range(start, end): @@ -254,7 +263,6 @@ cdef class Doc: # Set start as B self.c[start].ent_iob = 3 - @property def noun_chunks(self): """Yield spans for base noun phrases."""