Return True from doc.is_... when no ambiguity

* Make doc.is_sentenced return True if len(doc) < 2.

* Make doc.is_nered return True if len(doc) == 0, for consistency.

Closes #3934
This commit is contained in:
Matthew Honnibal 2019-07-10 19:21:23 +02:00
parent 465456edb9
commit 3d18600c05

View File

@ -240,6 +240,8 @@ cdef class Doc:
return True return True
if self.is_parsed: if self.is_parsed:
return True return True
if len(self) < 2:
return True
for i in range(1, self.length): for i in range(1, self.length):
if self.c[i].sent_start == -1 or self.c[i].sent_start == 1: if self.c[i].sent_start == -1 or self.c[i].sent_start == 1:
return True return True
@ -251,6 +253,8 @@ cdef class Doc:
*any* of the tokens has a named entity tag set (even if the others are *any* of the tokens has a named entity tag set (even if the others are
uknown values). uknown values).
""" """
if len(self) == 0:
return True
for i in range(self.length): for i in range(self.length):
if self.c[i].ent_iob != 0: if self.c[i].ent_iob != 0:
return True return True