So I am trying to build a a stater chatbot using Python v 3.7 (64 bit). I was able to install the chatterbot using pip... as well as installing the trainer and spaCy via the command prompt using Windows 10. There are other similar threads out there but I am a novice so I am probably missing something.
The first iteration of code I followed from **[https://www.geeksforgeeks.org/how-to-make-a-chatbot-in-python-using-chatterbot-module/**\]\[1\]
#importing libraries
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
#chatbot
chatbot = ChatBot("Sales AI")
#training chatbot
trainer = ListTrainer(chatbot)
trainer.train([
'Hi',
'Hello',
'I need roadmap for Competitive Programming',
'Just create an account on GFG and start',
'I have a query.',
'Please elaborate, your concern',
'How long it will take to become expert in Coding ?',
'It usually depends on the amount of practice.',
'Ok Thanks',
'No Problem! Have a Good Day!',
])
#conversational loop I suppose
while true:
request=input("you :")
if request == "OK" or request == 'ok':
print ("Sales AI: bye")
break
else:
response = chatbot.get_response("Good morning!")
print("Sales AI:", response)
From there I Run Module BUT I am presented with this error:
File "C:\Users\Me\AppData\Local\Programs\Python\Python37\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")
I saw a similar question asked when met with the same error here: ChatterBot error- OSError: [E941] Can't find model 'en' and applied this fix installing Spacy and the en core via Command Prompt terminal
python -m spacy download en_core_web_sm
Now when I Run Module, the en_core_web error from spaCy seems to have been resolved but I am presented with another issue but first look at the updated code below:
#importing libraries
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
#download spaCy language model via python shell
import spacy
from spacy.cli.download import download
download(model="en_core_web_sm")
#chatbot via https://www.geeksforgeeks.org/how-to-make-a-chatbot-in-python-using-chatterbot-module/
chatbot = ChatBot("Sales AI")
#training chatbot
trainer = ListTrainer(chatbot)
trainer.train([
'Hi',
'Hello',
'I need roadmap for Competitive Programming',
'Just create an account on GFG and start',
'I have a query.',
'Please elaborate, your concern',
'How long it will take to become expert in Coding ?',
'It usually depends on the amount of practice.',
'Ok Thanks',
'No Problem! Have a Good Day!',
])
#conversational loop I suppose
while true:
request=input("you :")
if request == "OK" or request == 'ok':
print ("Sales AI: bye")
break
else:
response = chatbot.get_response("Good morning!")
print("Sales AI:", response)
When I attempt to run this code I do not encounter an error at first but when I input "Hi" the following output occurs:
Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
= RESTART: C:/Users/Me/AppData/Local/Programs/Python/Python37/carsalesai.py
>>> Hi
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
Hi
NameError: name 'Hi' is not defined
So, I mad progress I believe but why does my chatbot not respond? It's taken me like 12hrs to get here. What should be my next steps?
Thank you fam!