spaCy - Doc._ _len_ _ Method



As name implies, this method of Doc class will get the number of tokens in the document.

Example

An example of Doc._ _len_ _is given below −

import spacy
nlp_model = spacy.load("en_core_web_sm")
doc = nlp_model("This is Tutorialspoint.com.")
len(doc)

Output

3
spacy_containers.htm
Advertisements