问题描述
我正在使用Google Colab中的spacy建立一个NER模型,为此我使用以下方式下载了spaCy'en_core_web_lg'模型
I am using spacy in google colab to build an NER model for which I have downloaded the spaCy 'en_core_web_lg' model using
import spacy.cli
spacy.cli.download("en_core_web_lg")
我收到一条消息
✔ Download and installation successful
You can now load the model via spacy.load('en_core_web_lg')
但是,当我尝试加载模型时
However then when i try to load the model
nlp = spacy.load('en_core_web_lg')
打印以下错误:
OSError: [E050] Can't find model 'en_core_web_lg'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.
有人可以帮助我解决这个问题吗?
Could anyone help me with this problem?
推荐答案
在使用Python 3内核的colab上,您应该都设置为在一个单元中运行(需要一段时间,但会为您提供有关进度的视觉反馈,与spacy.cli
)
On colab using a Python 3 kernel, you should be all set with running in one cell (takes a while, but gives you visual feedback about progress, differently from spacy.cli
)
!python -m spacy download en_core_web_lg
然后,重新启动colab运行时!
(要在colab菜单中执行此操作,请转到运行时">重新启动运行时...".
(to do this in the colab menu, go for Runtime > Restart runtime...).
之后,执行
import spacy
nlp = spacy.load('en_core_web_lg')
应该正常工作(在2019年底仍然适用于我).
should work flawlessly (it still does for me in late 2019).
这篇关于无法在Google colab上加载spacy模型'en_core_web_lg'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!