spaCy - Span._ _iter_ _ Method



This method of Span class will iterate over those token objects from which the annotations can be easily accessed.

Example

Refer the example of Span._ _iter_ _ method which is given below −

import spacy
nlp_model = spacy.load("en_core_web_sm")
doc = nlp_model("This is Tutorialspoint.com.")
span = doc[1:4]
[t.text for t in span]

Output

When you run the code, you will see the following output −

['is', 'Tutorialspoint.com', '.']
spacy_container_span_class.htm
Advertisements