gunthercox / ChatterBot

ChatterBot is a machine learning, conversational dialog engine for creating chat bots
https://chatterbot.readthedocs.io
BSD 3-Clause "New" or "Revised" License
14.01k stars 4.43k forks source link

quick start error #2194

Open bingo789 opened 3 years ago

bingo789 commented 3 years ago

first run error: no module named ‘spacy’. so I install spacy with cmd:

      pip install spacy
      python -m spacy download en_core_web_sm

then I run again but get another error:

File "/data/code/test/chatterbot_test/quick_start.py", line 4, in chatbot = ChatBot("Ron Obvious") File "/home/bingo/anaconda3/envs/pytorch/lib/python3.7/site-packages/chatterbot/chatterbot.py", line 28, in init self.storage = utils.initialize_class(storage_adapter, *kwargs) File "/home/bingo/anaconda3/envs/pytorch/lib/python3.7/site-packages/chatterbot/utils.py", line 33, in initialize_class return Class(args, kwargs) File "/home/bingo/anaconda3/envs/pytorch/lib/python3.7/site-packages/chatterbot/storage/sql_storage.py", line 20, in init super().init(kwargs) File "/home/bingo/anaconda3/envs/pytorch/lib/python3.7/site-packages/chatterbot/storage/storage_adapter.py", line 21, in init 'tagger_language', languages.ENG File "/home/bingo/anaconda3/envs/pytorch/lib/python3.7/site-packages/chatterbot/tagging.py", line 13, in init self.nlp = spacy.load(self.language.ISO_639_1.lower()) File "/home/bingo/anaconda3/envs/pytorch/lib/python3.7/site-packages/spacy/init.py", line 52, in load name, vocab=vocab, disable=disable, exclude=exclude, config=config File "/home/bingo/anaconda3/envs/pytorch/lib/python3.7/site-packages/spacy/util.py", line 327, in load_model raise IOError(Errors.E941.format(name=name, full=OLD_MODEL_SHORTCUTS[name])) 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") python-BaseException

Process finished with exit code 1

the source code looks like the class chatterbot.languages.ENG no support attr ISO_639_1 = 'en', use ISO_639_1 = 'en_core_web_sm' instead? or another ways?

the errors.py define:

OLD_MODEL_SHORTCUTS = { "en": "en_core_web_sm", "de": "de_core_news_sm", "es": "es_core_news_sm", "pt": "pt_core_news_sm", "fr": "fr_core_news_sm", "it": "it_core_news_sm", "nl": "nl_core_news_sm", "el": "el_core_news_sm", "nb": "nb_core_news_sm", "lt": "lt_core_news_sm", "xx": "xx_ent_wiki_sm" } so i guess use 'en_core_web_sm' instead 'en'

CuboidRaptor commented 2 years ago

Go to /home/bingo/anaconda3/envs/pytorch/lib/python3.7/site-packages/chatterbot/tagging.py and look for the line self.nlp = spacy.load(self.language.ISO_639_1.lower()) and replace it with:

if self.language.ISO_639_1.lower() == 'en':
    self.nlp = spacy.load('en_core_web_sm')

else:
    self.nlp = spacy.load(self.language.ISO_639_1.lower())