0

I have averaged_perceptron_tagger loaded here:

\\domain\Anaconda\envs\nlp\Lib\nltk_data\taggers\averaged_perceptron_tagger\averaged_perceptron_tagger.pickle

I am attempting to retrieve this tagger like this:

tagger = PerceptronTagger()

This results in this error:

Traceback (most recent call last):

  File "<ipython-input-18-58b392c276d2>", line 1, in <module>
    tagger = PerceptronTagger()

  File "\\domain\Anaconda\envs\nlp\lib\site-packages\nltk\tag\perceptron.py", line 170, in __init__
    self.load(AP_MODEL_LOC)

  File "\\domain\Anaconda\envs\nlp\lib\site-packages\nltk\tag\perceptron.py", line 253, in load
    self.model.weights, self.tagdict, self.classes = load(loc)

  File "\\domain\Anaconda\envs\nlp\lib\site-packages\nltk\data.py", line 752, in load
    opened_resource = _open(resource_url)

  File "\\domain\Anaconda\envs\nlp\lib\site-packages\nltk\data.py", line 880, in _open
    return find(path_, [""]).open()

  File "\\domain\Anaconda\envs\nlp\lib\site-packages\nltk\data.py", line 585, in find
    raise LookupError(resource_not_found)

LookupError: 
**********************************************************************
  Resource C: not found.
  Please use the NLTK Downloader to obtain the resource:

import nltk
nltk.download('C:')
  
  For more information see: https://www.nltk.org/data.html

  Attempted to load /C:/Users/username/domain/Anaconda/envs/nlp/lib/nltk_data/taggers/averaged_perceptron_tagger/averaged_perceptron_tagger.pickle

  Searched in:
    - ''
**********************************************************************

Why is nltk mashing two paths together (C:/Users/username & the full domain path where the tagger actually exists?

I tried calling the path directly like this...

tagger = nltk.data.load(r'\\domain\Anaconda\envs\nlp\Lib\nltk_data\taggers\averaged_perceptron_tagger\averaged_perceptron_tagger.pickle')

...which resulted in the same error.

OverflowingTheGlass
  • 2,324
  • 1
  • 27
  • 75
  • Take a look at https://stackoverflow.com/questions/36382937/nltk-doesnt-add-nltk-data-to-search-path/36383314#36383314 =) – alvas May 28 '21 at 02:02
  • thank you! I attempted the append as well, and the same error occurred (even after confirming that the new path was added to nltk.data. It's the mashing up of two paths that is stumping me. – OverflowingTheGlass May 28 '21 at 17:15

0 Answers0