Mannya
Mannya

Reputation: 135

NLTK corpora : IndexError: list index out of range

Here when I run this particular code

import os
import nltk
import nltk.corpus
print(os.listdir(nltk.data.find("corpora"))) `

I get

IndexError                                Traceback (most recent call 
last)
IndexError: list index out of range

Upvotes: 0

Views: 1236

Answers (1)

furas
furas

Reputation: 142661

I run this code without error.

If there is problem with data then you should get this error also with two lines:

import nltk 

print(nltk.data.find("corpora")) 

As I remember nltk at start needs to download data from server - and this can be the problem.

import nltk 

nltk.download()

See doc: Installing NLTK Data

Upvotes: 2

Related Questions