问题遇到的现象和发生背景
在使用chatterbot训练模型的时候,发生这个报错
问题相关代码,请勿粘贴截图
from chatterbot import ChatBot
import spacy
from chatterbot.trainers import ListTrainer
chatbot = ChatBot("Ron Obvious")
nlp = spacy.load("en_core_web_lg")
conversation = [
"Hello",
"Hi there!",
"How are you doing?",
"I'm doing great.",
"That is good to hear",
"Thank you.",
"You're welcome."
]
trainer = ListTrainer(chatbot)
trainer.train(conversation)
response = chatbot.get_response("Good morning!")
print(response)
运行结果及报错内容
C:\pyChrm123\mangshe\python.exe C:/Users/流浪猫汤姆/PycharmProjects/NLP/main.py
Traceback (most recent call last):
File "C:/Users/流浪猫汤姆/PycharmProjects/NLP/main.py", line 4, in
chatbot = ChatBot("Ron Obvious")
File "C:\pyChrm123\mangshe\lib\site-packages\chatterbot\chatterbot.py", line 28, in init
self.storage = utils.initialize_class(storage_adapter, **kwargs)
File "C:\pyChrm123\mangshe\lib\site-packages\chatterbot\utils.py", line 33, in initialize_class
return Class(*args, **kwargs)
File "C:\pyChrm123\mangshe\lib\site-packages\chatterbot\storage\sql_storage.py", line 20, in init
super().init(**kwargs)
File "C:\pyChrm123\mangshe\lib\site-packages\chatterbot\storage\storage_adapter.py", line 21, in init
'tagger_language', languages.ENG
File "C:\pyChrm123\mangshe\lib\site-packages\chatterbot\tagging.py", line 13, in init
self.nlp = spacy.load(self.language.ISO_639_1.lower())
File "C:\pyChrm123\mangshe\lib\site-packages\spacy_init_.py", line 52, in load
name, vocab=vocab, disable=disable, exclude=exclude, config=config
File "C:\pyChrm123\mangshe\lib\site-packages\spacy\util.py", line 426, in load_model
raise IOError(Errors.E941.format(name=name, full=OLD_MODEL_SHORTCUTS[name])) # type: ignore[index]
OSError: [E941] Can't find model 'en'. It looks like you're trying to load a model from a shortcut, which is obsolete as of spaCy v3.0. To load the model, use its full name instead:
nlp = spacy.load("en_core_web_sm")
For more details on the available models, see the models directory: https://spacy.io/models. If you want to create a blank model, use spacy.blank: nlp = spacy.blank("en")
Process finished with exit code 1
我的解答思路和尝试过的方法
en包的lg版本我已经pip安装了,但是还是报错,load不到sm后缀的包,可是我已经在代码前面声明load的是lg后缀的包,搞不懂它为什么还要报错sm后缀的包。
OSError: [E941] Can't find model 'en'. It looks like you're trying to load a model from a shortcut, which is obsolete as of spaCy v3.0. To load the model, use its full name instead:
针对这个报错结果,我试过注释报错代码,但是训练途中就会异常中断,结果如下:
E941报错是util.py文件里的 if name in OLD_MODEL_SHORTCUTS:
raise IOError(Errors.E941.format(name=name, full=OLD_MODEL_SHORTCUTS[name])) # type: ignore[index]
raise IOError(Errors.E050.format(name=name))
我想找一下OLD_MODEL_SHORTCUTS,但是在相调用的py文件里都没找到类似字符,我试过把报错信息注释,他就会训练到一半中断