How to config nltk data directory from code?
How to config nltk data directory from code?
Using fnjn's advice above on printing out the path:
print(nltk.data.path)
I saw the path strings in this type of format on windows:
C:\\Users\\my_user_name\\AppData\\Roaming\\SPB_Data
So I switched my path from the python type forward slash '/', to a double backslash '\\' when I used path.append:
nltk.data.path.append("C:\\workspace\\my_project\\data\\nltk_books")
The exception went away.
Another solution is to get ahead of it.
try import nltk nltk.download()
When the window box pops up asking if you want to download the corpus , you can specify there which directory it is to be downloaded to.