Maintain support for empty DocBin span groups (#10538)

This commit is contained in:
Adriane Boyd 2022-03-24 11:51:07 +01:00 committed by GitHub
parent 2ff197603e
commit 31a5d99efa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -147,7 +147,8 @@ class DocBin:
doc = Doc(vocab, words=tokens[:, orth_col], spaces=spaces) # type: ignore
doc = doc.from_array(self.attrs, tokens) # type: ignore
doc.cats = self.cats[i]
if self.span_groups[i] != SpanGroups._EMPTY_BYTES:
# backwards-compatibility: may be b'' or serialized empty list
if self.span_groups[i] and self.span_groups[i] != SpanGroups._EMPTY_BYTES:
doc.spans.from_bytes(self.span_groups[i])
else:
doc.spans.clear()