Skip to content

Commit

Permalink
let pipline support copy()
Browse files Browse the repository at this point in the history
  • Loading branch information
Vela-zz committed Dec 4, 2023
1 parent 0450298 commit f1cdb36
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions hanlp/components/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f1cdb36

Please sign in to comment.