Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
407 views
in Technique[技术] by (71.8m points)

python - 当我尝试下载StanfordNLP en模型时,出现错误(When I try to download StanfordNLP en model, it gives an error)

I am using Anaconda.

(我正在使用Anaconda。)

First I installed StanfordNLP and when I execute the command

(首先,我安装了StanfordNLP,并在执行命令时)

stanfordnlp.download('en')

it gives following error ;

(它给出以下错误 ;)

(base) C:UsersAbdullah>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:UsersAbdullahstanfordnlp_resources
Hit enter to continue or type an alternate directory.
C:UsersAbdullahDownloadsNew folder

Downloading models for: en_ewt
Download location: C:UsersAbdullahDownloadsNew folderen_ewt_models.zip
Traceback (most recent call last):
  File "C:UsersAbdullahAnaconda3libsite-packagesurllib3connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:UsersAbdullahAnaconda3libsite-packagesurllib3connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "C:UsersAbdullahAnaconda3libsite-packagesurllib3connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "C:UsersAbdullahAnaconda3libhttpclient.py", line 1321, in getresponse
    response.begin()
  File "C:UsersAbdullahAnaconda3libhttpclient.py", line 296, in begin
    version, status, reason = self._read_status()
  File "C:UsersAbdullahAnaconda3libhttpclient.py", line 257, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:UsersAbdullahAnaconda3libsocket.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:UsersAbdullahAnaconda3libsite-packages
equestsadapters.py", line 449, in send
    timeout=timeout
  File "C:UsersAbdullahAnaconda3libsite-packagesurllib3connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:UsersAbdullahAnaconda3libsite-packagesurllib3util
etry.py", line 368, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:UsersAbdullahAnaconda3libsite-packagesurllib3packagessix.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:UsersAbdullahAnaconda3libsite-packagesurllib3connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:UsersAbdullahAnaconda3libsite-packagesurllib3connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "C:UsersAbdullahAnaconda3libsite-packagesurllib3connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "C:UsersAbdullahAnaconda3libhttpclient.py", line 1321, in getresponse
    response.begin()
  File "C:UsersAbdullahAnaconda3libhttpclient.py", line 296, in begin
    version, status, reason = self._read_status()
  File "C:UsersAbdullahAnaconda3libhttpclient.py", line 257, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:UsersAbdullahAnaconda3libsocket.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:UsersAbdullahAnaconda3libsite-packagesstanfordnlputils
esources.py", line 137, in download
    confirm_if_exists=confirm_if_exists, force=force, version=version)
  File "C:UsersAbdullahAnaconda3libsite-packagesstanfordnlputils
esources.py", line 101, in download_ud_model
    r = requests.get(download_url, stream=True)
  File "C:UsersAbdullahAnaconda3libsite-packages
equestsapi.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "C:UsersAbdullahAnaconda3libsite-packages
equestsapi.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:UsersAbdullahAnaconda3libsite-packages
equestssessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "C:UsersAbdullahAnaconda3libsite-packages
equestssessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "C:UsersAbdullahAnaconda3libsite-packages
equestsadapters.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))

I am new to NLP .

(我是NLP的新手。)

  ask by Muhammad Abdullah translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If there is problem to download with

(如果下载有问题)

import stanfordnlp
stanfordnlp.download('en')

Then you can download it directly from web page StanfordNLP - Models and unpack to the folder which you see when you use stanfordnlp.download('en')

(然后,您可以从StanfordNLP-模型网页直接下载它,然后解压缩到使用stanfordnlp.download('en')时看到的文件夹。)

On Linux I got it in folder ~/stanfordnlp_resources/en_ewt_models/ and there are files

(在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

BTW: I had no problem to download it with stanfordnlp.download() with version 0.2.0 but I had also old version 0.1.0 and it was trying to download from different url which doesn't exist any more.

(顺便说一句:我没有问题可以使用stanfordnlp.download()进行下载,其版本为0.2.0但是我也使用的是旧版本0.1.0并且它正尝试从不再存在的其他URL下载。)

They moved files to different urls on server.

(他们将文件移动到服务器上的其他URL。)

import stanfordnlp
print(stanfordnlp.__version__)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...