chatterbot 1.0.8 incompatible with spacy 3.0.0
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
File "test.py", line 4, in
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")
Well... I talk whit spacy and tell me that. .
The problem here seems to be that Chatterbot hard-codes spacy.load("en") in its code, specifically in chatterbot/tagging.py. In spaCy v3, loading a model from a shortcut like en is deprecated, because this usage is misleading: there are many different en or es models, so it should always be clear which package is being loaded. For example, en_core_web_sm or es_core_web_sm.
So this is something that needs to be updated by Chatterbot in the future to support the new spaCy v3.
In the meantime, you can install spaCy v2 that still supports the shortcuts:
pip install spacy==2.3.5
I install... but not response my chatterbot in the web... suposly is work this.... the problem is I am novato no programer... I am musician...
Look...
Loaded compatibility table =====================
Installed models (spaCy v2.3.5
======================
spaCy instalación
/home/xxxxx/virtualenv/toni/3.7/lib/python3.7/site-packages/spacy
TYPE NAME MODEL VERSION
package es-core-news-sm
es_core_news_sm 2.3.1 ✔
package en-core-web_sm
en_core_web_sm 2.3.1 ✔
link en
en_core_web_sm 2.3.1 ✔
link es
es_core_news_sm 2.3.1 ✔
I uses in ssh this..
for english
pip install spacy==2.3.5 pip install spacy en_core_web_sm --force
for spanish
pip install spacy==2.3.5 pip install spacy es_core_news_sm --force
But not instaled 2.3.5 is 2.3.1...--circe .
2.3.1 still gives the same error for me. I guess it would easier to change the way chatterbot loads the corpus
See first what spacy do you have whit...
python -m spacy validate
If have 3.0 used
pip install spacy==2.3.5 pip install spacy en_core_web_sm --force
And...
pip install spacy==2.3.5
pip install spacy==2.3.5 en_core_web_sm
Collecting spacy==2.3.5
Downloading spacy-2.3.5-cp36-cp36m-manylinux2014_x86_64.whl (10.4 MB)
|████████████████████████████████| 10.4 MB 27 kB/s eta 0:00:01
ERROR: Could not find a version that satisfies the requirement en_core_web_sm (from versions: none)
ERROR: No matching distribution found for en_core_web_sm
can't install en_core_web_sm via pip
must install spacy first then run
python -m spacy download en_core_web_sm
Hey, dude try install spacy with >> pip install -U spacy
Before that, go to C:\python37\Lib\site-packages\chatterbot and open the file tagging.py and change the code
self.nlp = spacy.load(self.language.ISO_639_1.lower())
To
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())
try that ant tell me if work.
Install with:
pip install spacy==2.1.8
python -m spacy download es
Since class PosLemmaTagger loads spacy from self.language and StorageAdapter creates an instance of PosLemmaTagger with tagger_language:
class PosLemmaTagger(object):
def __init__(self, language=None):
self.language = language or languages.ENG
...
self.nlp = spacy.load(self.language.ISO_639_1.lower())
...
class StorageAdapter(object):
...
def __init__(self, *args, **kwargs):
...
self.tagger = PosLemmaTagger(language=kwargs.get(
'tagger_language', languages.ENG
))
...
You can load the chatbot by passing the language as a parameter to the Storage adapter, like this:
chatbot = ChatBot(
"MyBot",
storage_adapter={
'tagger_language': languages.SPA,
'import_path': 'chatterbot.storage.SQLStorageAdapter',
'database_uri': "...",
},
...
@andre0shazam gracias, tu solución funciono para mi.
I ran into the same problem when I was trying the tutorial. I'm new to ChatterBot so I'm not sure exactly what is the best way to solve the problem.
However, I wanted to approach working around this issue without messing around with the source code until a fix is in place. After reviewing the code, it was as simple as setting up a custom language class with the new model naming convention so here is my take at a workaround:
from chatterbot import ChatBot
# adding language for compatibility with spacy 3.0
class ENGSM:
ISO_639_1 = 'en_core_web_sm'
# Create a new instance of a ChatBot
bot = ChatBot(
"MyTestBot",
tagger_language=ENGSM # <-- pass this new language here
)
print("Type something to begin...")
# The following loop will execute each time the user enters input
while True:
try:
user_input = input()
bot_response = bot.get_response(user_input)
print(bot_response)
# Press ctrl-c or ctrl-d on the keyboard to exit
except (KeyboardInterrupt, EOFError, SystemExit):
break
It would be great for somebody to slap together a pull request for this
I have fixed the issue on pull request, please take a look on it and if everything seems okay, proceed with supporting this code to be included in next releases, and of course leave any suggestion or comment there so I can improve or fix anything you find
It's been over a year, the issue still persists in the latest version, and the PR is waiting for checks. What's up with the pipeline? :thinking:
It's been over a year, the issue still persists in the latest version, and the PR is waiting for checks. What's up with the pipeline? thinking
I have lost track of the documentation on how to setup and run the checks, if someone can point me to them I will gladly run those checks to submit the merge request.
Please fork this project if there is no progress here. There is so much free tech out there to make smart chatbots; people will need a place to integrate it.