我在本地主机上使用nltk运行python脚本。我的代码是:
#!C:\Users\fname lname\AppData\Local\Programs\Python\Python37-32\python.exe
print("Content-type: text/plain\n")
print("Single Quotes")
print("checkkk")
from nltk.tokenize import sent_tokenize, word_tokenize
EXAMPLE_TEXT = "Hello Mr. Smith, how are you doing today? The weather is great, and Python is awesome. The sky is pinkish-blue. You shouldn't eat cardboard."
print(sent_tokenize(EXAMPLE_TEXT))
输出为:
Single Quotes
checkkk
Content-type: text/plain
Single Quotes
checkkk
问题是:在此行之后,不考虑nltk导入和代码。请帮忙。
答案 0 :(得分:0)
检查是否为nltk.sent_tokenize()
下载了必要的数据文件。
使用nltk.download('punkt')
下载它们。