import spacy
import random
nlp=spacy.load('en')
TRAIN_DATA = [(u"Uber blew through $1 million a week", {"entities": [(0, 4, "ORG")]}),(u"Google rebrands its business apps", {"entities": [(0, 6, "ORG")]})]
nlp = spacy.blank('en')
optimizer = nlp.begin_training()
for i in range(20):
random.shuffle(TRAIN_DATA)
for text, annotations in TRAIN_DATA:
nlp.update([text], [annotations], sgd=optimizer)
nlp.to_disk("/model")
我试图以管理员权限在Python控制台上运行上述代码,但显示错误:
Warning: Unnamed vectors -- this won't allow multiple vectors models to be loaded. (Shape: (0, 0))
Traceback (most recent call last):
File "ss1.py", line 15, in <module>
nlp.to_disk("/model")
File "/Users/shailysaigal/anaconda3/lib/python3.7/site-packages/spacy/language.py", line 621, in to_disk
util.to_disk(path, serializers, {p: False for p in disable})
File "/Users/shailysaigal/anaconda3/lib/python3.7/site-packages/spacy/util.py", line 500, in to_disk
path.mkdir()
File "/Users/shailysaigal/anaconda3/lib/python3.7/pathlib.py", line 1241, in mkdir
self._accessor.mkdir(self, mode)
PermissionError: [Errno 13] Permission denied: '/model'
我已授予管理员特权,并尝试将spaCy升级到v2.0.12.dev0。