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()`.
This commit is contained in:
Adriane Boyd 2020-12-08 07:24:02 +01:00 committed by GitHub
parent 52fa46dd58
commit e931d3f72b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -434,10 +434,6 @@ class Language(object):
DOCS: https://spacy.io/api/language#call 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) doc = self.make_doc(text)
if component_cfg is None: if component_cfg is None:
component_cfg = {} component_cfg = {}
@ -464,6 +460,10 @@ class Language(object):
return DisabledPipes(self, *names) return DisabledPipes(self, *names)
def make_doc(self, text): 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) return self.tokenizer(text)
def _format_docs_and_golds(self, docs, golds): def _format_docs_and_golds(self, docs, golds):