spaCy - Span._ _getitem_ _ Method
This method of Span class is used to get a token object. at a particular position say n. Here n is an integer.
Argument
The table below explains its argument −
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| N | Integer | It represents the index of the token within the span. |
Example
An example of Span._ _getitem_ _ method is as follows −
import spacy
nlp_model = spacy.load("en_core_web_sm")
doc = nlp_model("This is Tutorialspoint.com.")
span = doc[1:4]
span[1].text
Output
When you run the code, you will see the following output −
'Tutorialspoint.com'
spacy_container_span_class.htm
Advertisements