diff --git a/website/docs/api/top-level.mdx b/website/docs/api/top-level.mdx index 975c16aaa..6de1acdf0 100644 --- a/website/docs/api/top-level.mdx +++ b/website/docs/api/top-level.mdx @@ -25,7 +25,10 @@ and call the package's own `load()` method. If a pipeline is loaded from a path, spaCy will assume it's a data directory, load its [`config.cfg`](/api/data-formats#config) and use the language and pipeline information to construct the `Language` class. The data will be loaded in via -[`Language.from_disk`](/api/language#from_disk). +[`Language.from_disk`](/api/language#from_disk). Loading a pipeline from a +package will also import any custom code, if present, whereas loading from a +directory does not. For these cases, you need to manually import your custom +code. diff --git a/website/docs/usage/rule-based-matching.mdx b/website/docs/usage/rule-based-matching.mdx index 55c043015..7e88bdc1f 100644 --- a/website/docs/usage/rule-based-matching.mdx +++ b/website/docs/usage/rule-based-matching.mdx @@ -1682,6 +1682,8 @@ def expand_person_entities(doc): if prev_token.text in ("Dr", "Dr.", "Mr", "Mr.", "Ms", "Ms."): new_ent = Span(doc, ent.start - 1, ent.end, label=ent.label) new_ents.append(new_ent) + else: + new_ents.append(ent) else: new_ents.append(ent) doc.ents = new_ents diff --git a/website/docs/usage/training.mdx b/website/docs/usage/training.mdx index 6cda975cb..6caf2e94b 100644 --- a/website/docs/usage/training.mdx +++ b/website/docs/usage/training.mdx @@ -758,6 +758,15 @@ any custom architectures, functions or your pipeline and registered when it's loaded. See the documentation on [saving and loading pipelines](/usage/saving-loading#models-custom) for details. + + +Note that the unpackaged models produced by `spacy train` are data directories +that **do not include custom code**. You need to import the code in your script +before loading in unpackaged models. For more details, see +[`spacy.load`](/api/top-level#spacy.load). + + + #### Example: Modifying the nlp object {id="custom-code-nlp-callbacks"} For many use cases, you don't necessarily want to implement the whole `Language`