From e931d3f72be04dfc0eb34831555ae2f66a90310e Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Tue, 8 Dec 2020 07:24:02 +0100 Subject: [PATCH] Move max_length to nlp.make_doc() (#6512) Move max_length check to `nlp.make_doc()` so that's it's also checked for `nlp.pipe()`. --- spacy/language.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spacy/language.py b/spacy/language.py index ee46da3c1..09476d3af 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -434,10 +434,6 @@ class Language(object): DOCS: https://spacy.io/api/language#call """ - if len(text) > self.max_length: - raise ValueError( - Errors.E088.format(length=len(text), max_length=self.max_length) - ) doc = self.make_doc(text) if component_cfg is None: component_cfg = {} @@ -464,6 +460,10 @@ class Language(object): return DisabledPipes(self, *names) def make_doc(self, text): + if len(text) > self.max_length: + raise ValueError( + Errors.E088.format(length=len(text), max_length=self.max_length) + ) return self.tokenizer(text) def _format_docs_and_golds(self, docs, golds):