我有一个文本文件(你可以从这里下载,这里)。
我正在尝试在文件中搜索单词
当我运行程序时,尽管文件中包含单词
为什么程序无法找到文件中存在的单词“language”?请注意,语句
感谢您的选择。
我正在尝试在文件中搜索单词
language
。为此,我拥有以下Python脚本:import nltk
file = open('NLTK.txt', 'r')
read_file = file.read()
text = nltk.Text(read_file)
match = text.concordance('language')
print(match)
当我运行程序时,尽管文件中包含单词
language
,但我得到了以下输出:No matches
None
为什么程序无法找到文件中存在的单词“language”?请注意,语句
text = nltk.Text(read_file)
返回:<Text: T h i s i s ...>
感谢您的选择。