spaCy - Span.has_extension Classmethod



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

Example

An example of Span.has_extension class method is as follows −

import spacy
nlp_model = spacy.load("en_core_web_sm")
from spacy.tokens import Span
Span.set_extension('is_city', default=False, force = True)
Span.has_extension('is_city')

Output

Upon execution, you will receive the following output −

True
spacy_container_span_class.htm
Advertisements