Resource punkt_tab not found. NLTK
Resource punkt_tab not found.
NLTK
Resource punkt_tab not found.
Please use the NLTK Downloader to obtain the resource:
解决方法:
import nltk
from nltk.tokenize import sent_tokenize
nltk.download('punkt_tab')
nltk.download('punkt') # 正确的资源名称是 "punkt"text = "Hello there. How are you?"
print(sent_tokenize(text)) # 应该能正常工作
结果:
['Hello there.', 'How are you?']