You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
859 B
30 lines
859 B
from django.core.management.base import BaseCommand
|
|
|
|
|
|
class Command(BaseCommand):
|
|
"""
|
|
A Django management command for calling a
|
|
chat bot's training method.
|
|
"""
|
|
|
|
help = 'Trains the database used by the chat bot'
|
|
can_import_settings = True
|
|
|
|
def handle(self, *args, **options):
|
|
from ..... import ChatBot
|
|
from ... import settings
|
|
|
|
chatterbot = ChatBot(**settings.CHATTERBOT)
|
|
|
|
chatterbot.train(chatterbot.training_data)
|
|
|
|
# Django 1.8 does not define SUCCESS
|
|
if hasattr(self.style, 'SUCCESS'):
|
|
style = self.style.SUCCESS
|
|
else:
|
|
style = self.style.NOTICE
|
|
|
|
self.stdout.write(style('Starting training...'))
|
|
training_class = chatterbot.trainer.__class__.__name__
|
|
self.stdout.write(style('ChatterBot trained using "%s"' % training_class))
|