spaCy - Doc.has_extension Classmethod
As name implies, this class method will check whether an extension has been registered on the Doc class or not.
Example
Refer the example for Doc.has_extension classmethod given below −
import spacy
nlp_model = spacy.load("en_core_web_sm")
from spacy.tokens import Doc
Doc.set_extension('has_city', default=False, force = True)
Doc.has_extension('has_city')
Output
The output is mentioned below −
True
spacy_containers.htm
Advertisements