spaCy - Token.has_extension Classmethod



As the name implies, this class method will check whether an extension has been registered on the Token class or not.

Argument

The table below explains its argument −

NAME TYPE DESCRIPTION
Name Unicode This argument represents the name of the extension to be checked.

Example

An example of Token.has_extension class method is given below −

import spacy
nlp_model = spacy.load("en_core_web_sm")
from spacy.tokens import Token
Token.set_extension("is_fruit", default=False, force=True)
Token.has_extension("is_fruit")

Output

The output is mentioned below −

True
spacy_container_token_class.htm
Advertisements