提问人:i222025 Amna Javaid 提问时间:11/9/2023 更新时间:11/9/2023 访问量:23
NLTK Python 库 Word Tokenizatio 错误 [已关闭]
nltk python library word tokenizatio error [closed]
问:
我正在尝试对文件进行标记。
`AttributeError Traceback (most recent call last)
<ipython-input-8-81ae6f78b554> in <cell line: 4>()
2 robert = open('Robert Frost.txt', 'r')
3 robert_poem = robert.read()
----> 4 robert_poem_words = nltk.word_tokenization(robert_poem)
# AttributeError: module 'nltk' has no attribute 'word_tokenization'`
错误出在word_tokenization函数中。
答:
1赞
naivebird
11/9/2023
#1
import nltk
nltk.download('punkt')
robert = open('Robert Frost.txt', 'r')
robert_poem = robert.read()
robert_poem_words = nltk.word_tokenize(robert_poem)
它不应该是.word_tokenize
word_tokenization
评论