ChatterBot icon indicating copy to clipboard operation
ChatterBot copied to clipboard

quick start error

Open bingo789 opened this issue 4 years ago • 1 comments

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'

bingo789 avatar Aug 27 '21 02:08 bingo789

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())

CuboidRaptor avatar Sep 13 '21 12:09 CuboidRaptor