NLTK Lookup Error

前端 未结 8 1685
感动是毒
感动是毒 2020-12-14 00:53

While running a Python script using NLTK I got this:

Traceback (most recent call last):
  File \"cpicklesave.py\", line 56, in 
    pos = nltk.         


        
相关标签:
8条回答
  • 2020-12-14 01:19

    If you have not downloaded ntlk then firstly download ntlk and then use this nltk.download('punkt') it will give you the result.

    0 讨论(0)
  • 2020-12-14 01:24

    You can download NLTK missing module just by

    import nltk
    nltk.download()
    

    This will shows the NLTK download screen. If it shows SSL Certificate verify failed error. Then it should works by disabling SSL check with below code!

    import nltk
    import ssl
    
    try:
        _create_unverified_https_context = ssl._create_unverified_context
    except AttributeError:
        pass
    else:
        ssl._create_default_https_context = _create_unverified_https_context
    
    nltk.download()
    
    0 讨论(0)
  • 2020-12-14 01:32

    Problem: Lookup error when extracting count vectorizer from scikit learn. Below is code snippet.

    from sklearn.feature_extraction.text import CountVectorizer
    bow_transformer = CountVectorizer(analyzer=text_process).fit(X)
    

    Solution: Try to run the below code and then try to install the stopwords from corpora natural language processing toolkit!!

    import nltk
    nltk.download()
    
    0 讨论(0)
  • 2020-12-14 01:33

    TL;DR

    import nltk
    nltk.download('averaged_perceptron_tagger')
    

    Or to download all packages + data + docs:

    import nltk
    nltk.download('all')
    

    See How do I download NLTK data?

    0 讨论(0)
  • 2020-12-14 01:37

    Use

    >>> nltk.download()
    

    to install the missing module (the Perceptron Tagger).

    (check also the answers to Failed loading english.pickle with nltk.data.load)

    0 讨论(0)
  • 2020-12-14 01:37

    First answer said the missing module is 'the Perceptron Tagger', actually its name in nltk.download is 'averaged_perceptron_tagger'

    You can use this to fix the error

    nltk.download('averaged_perceptron_tagger')

    0 讨论(0)
提交回复
热议问题