NLTK Python 库 Word Tokenizatio 错误 [已关闭]

nltk python library word tokenizatio error [closed]

提问人:i222025 Amna Javaid 提问时间:11/9/2023 更新时间:11/9/2023 访问量:23

问:


编辑问题以包括所需的行为、特定问题或错误以及重现问题所需的最短代码。这将帮助其他人回答这个问题。

10天前关闭。

我正在尝试对文件进行标记。

`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函数中。

python nlp nltk tokenize

评论

0赞 Ada 11/9/2023
如果没有看到你的代码,特别是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_tokenizeword_tokenization