NLTK and Stopwords Fail #lookuperror

后端 未结 6 757
我寻月下人不归
我寻月下人不归 2020-12-24 00:35

I am trying to start a project of sentiment analysis and I will use the stop words method. I made some research and I found that nltk have stopwords but when I execute the c

相关标签:
6条回答
  • 2020-12-24 01:04

    import nltk

    nltk.download()

    • A GUI pops up and in that go the Corpora section, select the required corpus.
    • Verified Result
    0 讨论(0)
  • 2020-12-24 01:05

    I tried from ubuntu terminal and I don't know why the GUI didn't show up according to tttthomasssss answer. So I followed the comment from KLDavenport and it worked. Here is the summary:

    Open your terminal/command-line and type python then

    >>> import nltk .>>> nltk.download("stopwords")

    This will store the stopwords corpus under the nltk_data. For my case it was /home/myusername/nltk_data/corpora/stopwords.

    If you need another corpus then visit nltk data and find the corpus with their ID. Then use the ID to download like we did for stopwords.

    0 讨论(0)
  • 2020-12-24 01:08
    import nltk
    nltk.download('stopwords')
    from nltk.corpus import stopwords
    STOPWORDS = set(stopwords.words('english'))
    
    0 讨论(0)
  • 2020-12-24 01:12

    You don't seem to have the stopwords corpus on your computer.

    You need to start the NLTK Downloader and download all the data you need.

    Open a Python console and do the following:

    >>> import nltk
    >>> nltk.download()
    showing info http://nltk.github.com/nltk_data/
    

    In the GUI window that opens simply press the 'Download' button to download all corpora or go to the 'Corpora' tab and only download the ones you need/want.

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

    Click on download button when gui prompted. It worked for me.(nltk.download('stopwords') doesn't work for me)

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

    If you want to manually install NLTK Corpus.

    1) Go to http://www.nltk.org/nltk_data/ and download your desired NLTK Corpus file.

    2) Now in a Python shell check the value of nltk.data.path

    3) Choose one of the path that exists on your machine, and unzip the data files into the corpora sub directory inside.

    4) Now you can import the data from nltk.corpos import stopwords

    Reference: https://medium.com/@satorulogic/how-to-manually-download-a-nltk-corpus-f01569861da9

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