How to break up document by sentences with Spacy(如何使用Spacy按句拆分文档)
问题描述
如何将文档(如段落、书籍等)拆分成句子。
例如"The dog ran. The cat jumped"
into["The dog ran", "The cat jumped"]
with spacy?
推荐答案
最新答案如下:
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]
这篇关于如何使用Spacy按句拆分文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!