我正在使用Anaconda。首先,我安装了 StanfordNLP ,并在执行命令时
stanfordnlp.download('en')
它给出以下错误;
(base) C:\Users\Abdullah>python
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import stanfordnlp
>>> stanfordnlp.download('en')
Using the default treebank "en_ewt" for language "en".
Would you like to download the models for: en_ewt now? (Y/n)
y
Default download directory: C:\Users\Abdullah\stanfordnlp_resources
Hit enter to continue or type an alternate directory.
C:\Users\Abdullah\Downloads\New folder
Downloading models for: en_ewt
Download location: C:\Users\Abdullah\Downloads\New folder\en_ewt_models.zip
Traceback (most recent call last):
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Abdullah\Anaconda3\lib\http\client.py", line 1321, in getresponse
response.begin()
File "C:\Users\Abdullah\Anaconda3\lib\http\client.py", line 296, in begin
version, status, reason = self._read_status()
File "C:\Users\Abdullah\Anaconda3\lib\http\client.py", line 257, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\Abdullah\Anaconda3\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\urllib3\util\retry.py", line 368, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Abdullah\Anaconda3\lib\http\client.py", line 1321, in getresponse
response.begin()
File "C:\Users\Abdullah\Anaconda3\lib\http\client.py", line 296, in begin
version, status, reason = self._read_status()
File "C:\Users\Abdullah\Anaconda3\lib\http\client.py", line 257, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\Abdullah\Anaconda3\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\stanfordnlp\utils\resources.py", line 137, in download
confirm_if_exists=confirm_if_exists, force=force, version=version)
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\stanfordnlp\utils\resources.py", line 101, in download_ud_model
r = requests.get(download_url, stream=True)
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Abdullah\Anaconda3\lib\site-packages\requests\adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
我是 NLP 的新手。
答案 0 :(得分:0)
如果下载有问题
import stanfordnlp
stanfordnlp.download('en')
然后,您可以直接从网页StanfordNLP - Models下载它,然后解压缩到使用stanfordnlp.download('en')
时看到的文件夹
在Linux上,我将其保存在文件夹~/stanfordnlp_resources/en_ewt_models/
中,并且有文件
en_ewt.pretrain.pt
en_ewt_lemmatizer.pt
en_ewt_parser.pt
en_ewt_tagger.pt
en_ewt_tokenizer.pt
顺便说一句::我没问题用stanfordnlp.download()
的{{1}}版本进行下载,但是我也有旧版本的0.2.0
,它正尝试从中下载不存在的其他网址。他们将文件移动到服务器上的其他URL。
0.1.0