From 492c94893781151c7b25d73a95cfc93cd5c9b014 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 25 Jan 2021 00:51:38 +1100 Subject: [PATCH] Add SpanGroups.copy method --- spacy/tokens/_dict_proxies.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spacy/tokens/_dict_proxies.py b/spacy/tokens/_dict_proxies.py index b10f6d484..bfc867ffa 100644 --- a/spacy/tokens/_dict_proxies.py +++ b/spacy/tokens/_dict_proxies.py @@ -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.