spaCy - Doc.sents Property



As name suggests, this doc property is used to iterate over the sentences in a particular document. If the parser is disabled, then the sents iterator will be unavailable.

Example 1

Refer the example of Doc.sents property given below −

import spacy
nlp_model = spacy.load("en_core_web_sm")
doc = nlp_model("The website is Tutorialspoint.com. It is having best technical tutorials.")
sents = list(doc.sents)
len(sents)

Output

You will get the following output −

2

Example 2

An another example of Doc.sents property is given below −

[a.root.text for a in sents]

Output

['is', 'having']
spacy_doc_class_contextmanager_and_property.htm
Advertisements