spaCy - Util.load_model



It is introduced in version 2.0 and is like spacy.load() function. As the name implies, this utility function will load a model via the following −

  • Its shortcut links.

  • The name of the installed model package

  • A Unicode paths.

  • Path-like object.

  • If a model is loaded from a shortcut link or package name, spaCy will assume it as a Python package and call the model’s own load() method.

  • On the other hand, if a model is loaded from a path, spacy will assume it is a data directory and hence initialize the Language class.

Arguments

The table below explains its arguments −

NAME TYPE DESCRIPTION
name unicode / Path It is the shortcut link, package name or path of the model to load.
disable List It represents the names of pipeline components to disable.

Example

An example for util.load_model() utility function is stated below −

import spacy

Following is an example of util.load_model utility function by using the shortcut link

nlp_model = spacy.util.load_model("en")

Following is an example of util.load_model utility function by using the package

nlp_model = spacy.util.load_model("en_core_web_sm")

Following is an example of util.load_model utility function by using the Unicode path

nlp_model = spacy.util.load_model ("/path/to/data")
spacy_util_get_data_path.htm
Advertisements