Resource punkt not found. Please use the NLTK Downloader to obtain the resource: >>> import nltk >>> nltk.download('punkt')
Asked Answered
E

4

8

I have NLTK installed and it is going me error Resource punkt not found. Please use the NLTK Downloader to obtain the resource:

import nltk nltk.download('punkt') For more information see: https://www.nltk.org/data.html

Attempted to load tokenizers/punkt/PY3/english.pickle

Searched in: - '/Users/divyanshundley/nltk_data' - '/Library/Frameworks/Python.framework/Versions/3.10/nltk_data' - '/Library/Frameworks/Python.framework/Versions/3.10/share/nltk_data' - '/Library/Frameworks/Python.framework/Versions/3.10/lib/nltk_data' - '/usr/share/nltk_data' - '/usr/local/share/nltk_data' - '/usr/lib/nltk_data' - '/usr/local/lib/nltk_data' - ''


and my code is

import nltk
nltk.download('punkt')

def tokenize(token):
    return nltk.word_tokenize(token);
tokenize("why is this not working?");
Emyle answered 16/9, 2022 at 12:10 Comment(6)
Have you done what the error tells you?Skim
yeah I have done the following :Emyle
pip install --user -U nltkEmyle
pip install --user -U numpyEmyle
The error tells you neither of those, it tells you to use nltk.download('punkt')Skim
so , should I put nltk.download('punkt') in my code?Emyle
R
5

Please download the below also. This will resolve your issue:

nltk.download('punkt')
nltk.download('wordnet')
nltk.download('omw-1.4')
Remington answered 13/10, 2022 at 18:16 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Voracity
D
2

I was having the same issue, but the cause was different.

I was getting an error message that punkt was missing but that wasn't the problem, the error message was a bug.

The problem was that the language variable was placed in the wrong position in the method call.

If you need to use the "preserve line" parameter, make sure you assign a value to the language variable, since it's a positional parameter. A valid call of word_tokenize would be:

nltk.word_tokenize('My beautiful house is Awesome. My car is too.', language='english', preserve_line=True)
Daina answered 2/1 at 18:58 Comment(0)
B
0

I simply find that punkt is just already in the directory:

"C:\Users\username\AppData\Roaming\nltk_data\tokenizers"

However, the nklt module only tries to search

"C:\Users\s1111\AppData\Roaming\nltk_data"

without the "tokenizers" directory. So, just find the punky file in the first directory and copy it to the second directory. No need to download any files.

Baily answered 20/11, 2023 at 9:43 Comment(0)
U
-2

Executing these lines in Jupyter Notebook allowed me to tokenize successfully.

(Executing these lines launches the NLTK downloader) import nltk nltk.download()

From the menu I selected (d) Download then entered the "book" for the corpus to download, then (q) to quit.

(These lines then successfully tokenized the sentence)

from nltk.tokenize import word_tokenize word_tokenize("Let's learn machine learning")

Jupyter Notebook Image 1

Jupyter Notebook Image 2

Unshod answered 5/1, 2023 at 16:13 Comment(1)

© 2022 - 2024 — McMap. All rights reserved.