使用spaCy分割文本可以通过以下步骤实现:
pip install spacy
python -m spacy download en_core_web_sm
import spacy
nlp = spacy.load('en_core_web_sm')
text = "This is a sample text. SpaCy can split this text into sentences."
doc = nlp(text)
sentences = [sent.text for sent in doc.sents]
print(sentences)
输出结果将是分割后的句子列表:
['This is a sample text.', 'SpaCy can split this text into sentences.']
通过以上步骤,你可以使用spaCy库来对文本进行分割并提取句子。