无法加载Word2Vec-google-news-300

1.错误提示

无法直接下载'word2vec-google-news-300'
输入代码:

import gensim.downloader as api
wv = api.load('word2vec-google-news-300')

获得报错:

remote end closed connection without response

2.解决办法

2.1 手动下载数据

① 数据

在下面的网站找到的

The archive is available here: GoogleNews-vectors-negative300.bin.gz.(←这里下载)

!!word2vec-google-news-300(←没法翻墙就这里下载)
提取码: word

② 解压

手动下载下来word2vec-google-news-300.gz,将解压后的文件GoogleNews-vectors-negative300.bin放在~/gensim-data/word2vec-google-news-300目录下

但是再运行上述代码,还是会报错:
在这里插入图片描述

2.2

再使用以下代码:

from gensim.models import KeyedVectors
from gensim.test.utils import datapath
wv_from_bin = KeyedVectors.load_word2vec_format(datapath(r"~/gensim-data/word2vec-google-news-300/GoogleNews-vectors-negative300.bin"), binary=True)

在这里插入图片描述
可以了!

3.参考博客

AttributeError:module ‘word2vec-google-news-300’ has no attribute ‘load data’