diff --git a/hanlp/components/pipeline.py b/hanlp/components/pipeline.py index 7f700b1e7..c6156f497 100644 --- a/hanlp/components/pipeline.py +++ b/hanlp/components/pipeline.py @@ -145,15 +145,21 @@ def __call__(self, doc: Union[Document, Any] = None, **kwargs) -> Document: for component in self: doc = component(doc) return doc - + + def copy(self): + return self.__copy__() + + def __copy__(self): + config = self.meta + return Pipeline.from_config(config) + @property def meta(self): return { 'classpath': classpath_of(self), 'hanlp_version': hanlp.version.__version__, 'pipes': [pipe.config for pipe in self] - } - + } @meta.setter def meta(self, value): pass