chatter bot training
nvp18 opened this issue · 1 comments
nvp18 commented
i am using django for chatterbot i want to train the chatbot using seperate train .py file when i import the settings from chatterbot.ext.django_chatterbot i am getting an error
Traceback (most recent call last):
File "train.py", line 3, in <module>
from chatterbot.ext.django_chatterbot import settings
File "C:\Users\nuthalapativ\AppData\Local\Continuum\anaconda3\lib\site-packages\chatterbot\ext\django_chatterbot\settings.py", line 8, in <module>
CHATTERBOT_SETTINGS = getattr(settings, 'CHATTERBOT', {})
File "C:\Users\nuthalapativ\AppData\Local\Continuum\anaconda3\lib\site-packages\django\conf\__init__.py", line 79, in __getattr__
self._setup(name)
File "C:\Users\nuthalapativ\AppData\Local\Continuum\anaconda3\lib\site-packages\django\conf\__init__.py", line 64, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting CHATTERBOT, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
can you help me on this
the program that i have written is
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from chatterbot.ext.django_chatterbot import settings
bot = ChatBot(**settings.CHATTERBOT)
trainer =ChatterBotCorpusTrainer(bot)
trainer.train('./training_data/')
mohapsat commented
Here's one way to go about it. Create a training.py in your django app folder. Inside training.py create your training data as a list
static_qa = [
"Hello", "Hi there!",
"How are you doing", "I'm doing great, thank you for asking!",
]
in your views.py
from .training import static_qa
then after you create a chatterbot instance:
trainer = ListTrainer(chatterbot)
try:
trainer.train(static_qa) # static_qa list
except Exception as e:
logging.error(f"error training static qa = {e}")
List Trainer: [####################] 100%