Add SpanGroups.copy method

This commit is contained in:
Matthew Honnibal 2021-01-25 00:51:38 +11:00
parent 8a22161b59
commit 492c948937

View File

@ -33,6 +33,9 @@ class SpanGroups(UserDict):
def _make_span_group(self, name: str, spans: Iterable["Span"]) -> SpanGroup:
return SpanGroup(self.doc_ref(), name=name, spans=spans)
def copy(self) -> "SpanGroups":
return SpanGroup(self.doc_ref()).from_bytes(self.to_bytes())
def to_bytes(self) -> bytes:
# We don't need to serialize this as a dict, because the groups
# know their names.