spaCy - Span.get_extension Classmethod



As the name implies, this class method will look up for a previous extension by name. It was also introduced in version 2.0 and will return a 4-tuple (default, method, getter, setter) value.

Example

An example of Span.get_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)
extension = Span.get_extension('is_city')
extension

Output

Upon execution, you will receive the following output −

(False, None, None, None)
spacy_container_span_class.htm
Advertisements