From 06c3a5e048dc740bbe482d994505512845a6fd9f Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Thu, 6 Aug 2020 19:43:09 +0200 Subject: [PATCH] Add pipe to AttributeRuler (#5889) --- spacy/pipeline/attributeruler.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spacy/pipeline/attributeruler.py b/spacy/pipeline/attributeruler.py index d5abf7863..6d73da9ca 100644 --- a/spacy/pipeline/attributeruler.py +++ b/spacy/pipeline/attributeruler.py @@ -89,6 +89,21 @@ class AttributeRuler(Pipe): set_token_attrs(token, attrs) return doc + def pipe(self, stream, *, batch_size=128): + """Apply the pipe to a stream of documents. This usually happens under + the hood when the nlp object is called on a text and all components are + applied to the Doc. + + stream (Iterable[Doc]): A stream of documents. + batch_size (int): The number of documents to buffer. + YIELDS (Doc): Processed documents in order. + + DOCS: https://spacy.io/attributeruler/pipe#pipe + """ + for doc in stream: + doc = self(doc) + yield doc + def load_from_tag_map( self, tag_map: Dict[str, Dict[Union[int, str], Union[int, str]]] ) -> None: