Using NLTK corpora with AWS Lambda functions in Python

后端 未结 4 1776
遥遥无期
遥遥无期 2021-01-02 02:20

I\'m encountering a difficulty when using NLTK corpora (in particular stop words) in AWS Lambda. I\'m aware that the corpora need to be downloaded and have done so with NLTK

4条回答
  •  走了就别回头了
    2021-01-02 02:48

    If your stopwords corpus is under /nltk_data (based on root, not under your home directory), you need to tell the nltk before you try to access a corpus:

    from nltk.corpus import stopwords
    nltk.data.path.append("/nltk_data")
    
    stopwords = stopwords.words('english')
    

提交回复
热议问题