diff --git a/spacy/errors.py b/spacy/errors.py index 4d66fd0ef..17868b605 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -483,9 +483,10 @@ class Errors: "component that doesn't seem to support listeners. Expected Tok2Vec " "or Transformer component. If you didn't call nlp.replace_listeners " "manually, this is likely a bug in spaCy.") - E889 = ("Can't replace listeners of component '{name}' because it's not " - "in the pipeline. Available components: {opts}. If you didn't call " - "nlp.replace_listeners manually, this is likely a bug in spaCy.") + E889 = ("Can't replace '{tok2vec}' listeners of component '{name}' because " + "'{unknown}' is not in the pipeline. Available components: {opts}. " + "If you didn't call nlp.replace_listeners manually, this is likely " + "a bug in spaCy.") E890 = ("Cannot add the alias '{alias}' to the Knowledge base. " "Each alias should be a meaningful string.") E891 = ("Alias '{alias}' could not be added to the Knowledge base. " diff --git a/spacy/language.py b/spacy/language.py index 92710024f..3c7f91dd6 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -1712,10 +1712,20 @@ class Language: DOCS: https://nightly.spacy.io/api/language#replace_listeners """ if tok2vec_name not in self.pipe_names: - err = Errors.E889.format(name=tok2vec_name, opts=", ".join(self.pipe_names)) + err = Errors.E889.format( + tok2vec=tok2vec_name, + name=pipe_name, + unknown=tok2vec_name, + opts=", ".join(self.pipe_names), + ) raise ValueError(err) if pipe_name not in self.pipe_names: - err = Errors.E889.format(name=pipe_name, opts=", ".join(self.pipe_names)) + err = Errors.E889.format( + tok2vec=tok2vec_name, + name=pipe_name, + unknown=pipe_name, + opts=", ".join(self.pipe_names), + ) raise ValueError(err) tok2vec = self.get_pipe(tok2vec_name) tok2vec_cfg = self.get_pipe_config(tok2vec_name)