nltk下载错误的终极解决办法[Errno 61] Connection refused

错误描述

在python命令行下

import nltk
nltk.download()

会出现

nltk下载错误的终极解决办法[Errno 61] Connection refused_第1张图片 解决办法

1、下载这个https://github.com/nltk/nltk_data/tree/gh-pages

2、解压后是名为nltk_data-gh-pages的文件夹

3、在上面Download Directory的路径下新建一个文件夹nltk_data(空的)

4、把nltk_data-gh-pages文件夹中packages中所有的文件夹拷贝到nltk_data中

5、在python命令行下执行如下命令

import nltk
from nltk.book import *

出现如下表示安装成功

>>> from nltk.book import *
*** Introductory Examples for the NLTK Book ***
Loading text1, ..., text9 and sent1, ..., sent9
Type the name of the text or sentence to view it.
Type: 'texts()' or 'sents()' to list the materials.
text1: Moby Dick by Herman Melville 1851
text2: Sense and Sensibility by Jane Austen 1811
text3: The Book of Genesis
text4: Inaugural Address Corpus
text5: Chat Corpus
text6: Monty Python and the Holy Grail
text7: Wall Street Journal
text8: Personals Corpus
text9: The Man Who Was Thursday by G . K . Chesterton 1908

很多人讲到这里就没了,接下来如何引入stopwords呢?

from nltk import stopwords

这样式不行的!!!!!

应该这样用

from nltk.corpus import stopwords

 

你可能感兴趣的:(python,python,nltk)