请编写一个程序能够对一段英文进行按句分词
时间: 2024-04-29 14:24:58 浏览: 155
python 对英文句子分词 ,去重,排序(csdn)————程序.pdf
Sure, I can help you with that. Here's a basic Python code using the Natural Language Toolkit (NLTK) library to perform sentence segmentation:
```
import nltk
text = "This is a sample sentence. And here's another one. Finally, we have a third sentence."
sentences = nltk.sent_tokenize(text)
print(sentences)
```
Output:
```
['This is a sample sentence.', "And here's another one.", 'Finally, we have a third sentence.']
```
This code splits the input text into sentences using the `sent_tokenize()` function from NLTK. You can modify the `text` variable to contain any English text you want to tokenize.
阅读全文