0

I have a script which utilizes NLTK's WordNetLemmatizer, which, in turn, requires corpora/wordnet to be present in a certain location on the user's system. WordNetLemmatizer is imported as follows:

from nltk.stem.wordnet import WordNetLemmatizer

My script (actually, a pretty hefty program) is compiled into an executable, and I can't expect the end-user to install NLTK components. I'd like to include corpora/wordnet in my program's directory.

Is there a way to get WordNetLemmatizer to look for corpora/wordnet in an explicitly specified location, in particular, in the same directory as the executable file generated from my python script?

Boa
  • 2,609
  • 1
  • 23
  • 38

1 Answers1

4

have you tried to add the following line to your script?

nltk.path.append('/home/user/some_directory/nltk_data/')

Regards, Grzegorz

gbajson
  • 1,531
  • 13
  • 32