Resource punkt not found. Please use the NLTK Downloader to obtain the resource: >>> import nltk >>> nltk.download('punkt')
Question:
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?");
Answers:
Please download the below also. This will resolve your issue:
*nltk.download('punkt')
nltk.download('wordnet')
nltk.download('omw-1.4'*
)
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"
)
I simply find that punkt is just already in the directory:
"C:UsersusernameAppDataRoamingnltk_datatokenizers"
However, the nklt module only tries to search
"C:Userss1111AppDataRoamingnltk_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.
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 on the wrong order on the method call.
If you need to use the preserve line parameter, make sure you assign a value to the language variable, since its 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)
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?");
Please download the below also. This will resolve your issue:
*nltk.download('punkt')
nltk.download('wordnet')
nltk.download('omw-1.4'*
)
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"
)
I simply find that punkt is just already in the directory:
"C:UsersusernameAppDataRoamingnltk_datatokenizers"
However, the nklt module only tries to search
"C:Userss1111AppDataRoamingnltk_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.
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 on the wrong order on the method call.
If you need to use the preserve line parameter, make sure you assign a value to the language variable, since its 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)