Fix clobber of doc.is_tagged in doc.from_array()

If doc.from_array() was called with say, only entity information, this
would cause doc.is_tagged to be set to False, even if tags were set.
This caused tags to be dropped from serialisation. The same was true for
doc.is_parsed.

Closes #3012.
This commit is contained in:
Matthew Honnibal 2018-12-30 15:48:10 +01:00
parent bf20252ae0
commit d8d0ce081b
1 changed files with 2 additions and 2 deletions

View File

@ -708,8 +708,8 @@ cdef class Doc:
if array[i, col] != 0: if array[i, col] != 0:
self.vocab.morphology.assign_tag(&tokens[i], array[i, col]) self.vocab.morphology.assign_tag(&tokens[i], array[i, col])
# set flags # set flags
self.is_parsed = bool(HEAD in attrs or DEP in attrs) self.is_parsed = bool(self.is_parsed or HEAD in attrs or DEP in attrs)
self.is_tagged = bool(TAG in attrs or POS in attrs) self.is_tagged = bool(self.is_tagged or TAG in attrs or POS in attrs)
# if document is parsed, set children # if document is parsed, set children
if self.is_parsed: if self.is_parsed:
set_children_from_heads(self.c, self.length) set_children_from_heads(self.c, self.length)