How can I break a document (e.g., paragraph, book, etc) into sentences.
For example, "The dog ran. The cat jumped" into ["The dog ran", "The cat jumped"] with spacy?
The up-to-date answer is this:
from __future__ import unicode_literals, print_function
from spacy.lang.en import English # updated
raw_text = 'Hello, world. Here are two sentences.'
nlp = English()
nlp.add_pipe(nlp.create_pipe('sentencizer')) # updated
doc = nlp(raw_text)
sentences = [sent.string.strip() for sent in doc.sents]
From spacy's github support page
from __future__ import unicode_literals, print_function
from spacy.en import English
raw_text = 'Hello, world. Here are two sentences.'
nlp = English()
doc = nlp(raw_text)
sentences = [sent.string.strip() for sent in doc.sents]
来源:https://stackoverflow.com/questions/46290313/how-to-break-up-document-by-sentences-with-with-spacy