Usually you’ll load this once per process as nlp and pass the instance around
your application. The Language class is created when you call
spacy.load() and contains the shared vocabulary
and language data, optional model data loaded from a
model package or a path, and a
processing pipeline containing components like
the tagger or parser that are called on a document in order. You can also add
your own processing pipeline components that take a Doc object, modify it and
Add a component to the processing pipeline. Valid components are callables that
take a Doc object, modify it and return it. Only one of before, after,
first or last can be set. Default behavior is last=True.
The pipeline component.
Name of pipeline component. Overwrites existing component.name attribute if available. If no name is set and the component exposes no name attribute, component.__name__ is used. An error is raised if the name already exists in the pipeline.
Component name to insert component directly before.
Component name to insert component directly after:
Insert component first / not first in the pipeline.
Rename a component in the pipeline. Useful to create custom names for
pre-defined and pre-loaded components. To change the default name of a component
added to the pipeline, you can also use the name argument on
Disable one or more pipeline components. If used as a context manager, the
pipeline will be restored to the initial state at the end of the block.
Otherwise, a DisabledPipes object is returned, that has a .restore() method
you can use to undo your changes.
Names of pipeline components to disable.
The disabled pipes that can be restored by calling the object’s .restore() method.
Loads state from a directory. Modifies the object in place and returns it. If
the saved Language object contains a model, the model will be loaded. Note
that this method is commonly used via the subclasses like English or German
to make language-specific functionality like the
lexical attribute getters available to the
unicode / Path
A path to a directory. Paths may be either strings or Path-like objects.
Load state from a binary string. Note that this method is commonly used via the
subclasses like English or German to make language-specific functionality
like the lexical attribute getters
available to the loaded object.
During serialization, spaCy will export several data fields used to restore
different aspects of the object. If needed, you can exclude them from
serialization by passing in the string names via the exclude argument.