2

I try to use nltk library, but i got stuck. I downloaded the stopwords library by hand (I cant download by code because of the permission issues on my working machine), but it always gives me the following error;

LookupError: 
**********************************************************************
  Resource stopwords not found.
  Please use the NLTK Downloader to obtain the resource:
....
Searched in:
  - '/home/skahraman/nltk_data'
....

My stopwords in nltk_data folder. So how can i solve this problem?

I tried following;

import string
import nltk
from nltk import word_tokenize
from nltk.corpus import stopwords
from collections import Counter
#nltk.download('stopwords')
nltk.data.path.append("/home/skahraman/nltk_data")
stop_words=stopwords.words("turkish")
Sevval Kahraman
  • 1,185
  • 3
  • 10
  • 37

2 Answers2

1

it seems you are not properly assigning a file path to the nlkt.data module. I also noticed a very similar issue, try specifying the path using tempfile.gettempdir and download it.

import tempfile
import string
import nltk
from nltk import word_tokenize
from nltk.corpus import stopwords
from collections import Counter

download('stopwords', download_dir=tempfile.gettempdir())
nltk.data.path.append(tempfile.gettempdir())
stop_words=stopwords.words("turkish")
user11717481
  • 1
  • 9
  • 15
  • 25
  • Thanks for your answer, but i cant download file like this because of the permission issues so i have to do it by hand. So i download into /home/skahraman/nltk_data folder. – Sevval Kahraman Apr 26 '22 at 07:01
1

My folder path was ; /home/skahraman/nltk_data/stopwords

But it must be ; /home/skahraman/nltk_data/corpora/stopwords

I added the corpora folder to my directory. So it works now.

Sevval Kahraman
  • 1,185
  • 3
  • 10
  • 37