How to use the chatterbot.trainers.ChatterBotCorpusTrainer function in ChatterBot

To help you get started, we’ve selected a few ChatterBot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gunthercox / ChatterBot / tests_django / test_chatterbot_corpus_training.py View on Github external
def setUp(self):
        super().setUp()

        self.trainer = ChatterBotCorpusTrainer(
            self.chatbot,
            show_training_progress=False
        )
github gunthercox / ChatterBot / tests / training_tests / test_corpus_training.py View on Github external
def setUp(self):
        super(ChatterBotCorpusTrainingTests, self).setUp()
        self.chatbot.set_trainer(ChatterBotCorpusTrainer)
github gunthercox / ChatterBot / examples / learning_new_response.py View on Github external
from chatterbot.trainers import ChatterBotCorpusTrainer


# Uncomment the following line to enable verbose logging
# import logging
# logging.basicConfig(level=logging.INFO)

# Create a new instance of a ChatBot
bot = ChatBot(
    "Terminal",
    storage_adapter="chatterbot.storage.SQLStorageAdapter",
    input_adapter="chatterbot.input.TerminalAdapter",
    output_adapter="chatterbot.output.TerminalAdapter"
)

trainer = ChatterBotCorpusTrainer(bot)

trainer.train("chatterbot.corpus.english")


def get_feedback():

    text = input()

    if 'yes' in text.lower():
        return False
    elif 'no' in text.lower():
        return True
    else:
        print('Please type either "Yes" or "No"')
        return get_feedback()
github gunthercox / ChatterBot / examples / microsoft_bot.py View on Github external
'''
See the Microsoft DirectLine api documentation for how to get a user access token.
https://docs.botframework.com/en-us/restapi/directline/
'''

chatbot = ChatBot(
    'MicrosoftBot',
    directline_host=Microsoft['directline_host'],
    direct_line_token_or_secret=Microsoft['direct_line_token_or_secret'],
    conversation_id=Microsoft['conversation_id'],
    input_adapter='chatterbot.input.Microsoft',
    output_adapter='chatterbot.output.Microsoft'
)

trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train('chatterbot.corpus.english')

# The following loop will execute each time the user enters input
while True:
    try:
        response = chatbot.get_response('')

    # Press ctrl-c or ctrl-d on the keyboard to exit
    except (KeyboardInterrupt, EOFError, SystemExit):
        break
github gunthercox / ChatterBot / examples / gitter_example.py View on Github external
"API_TOKEN": "my-api-token",
    "ROOM": "example_project/test_room"
}
'''


chatbot = ChatBot(
    'GitterBot',
    gitter_room=GITTER['ROOM'],
    gitter_api_token=GITTER['API_TOKEN'],
    gitter_only_respond_to_mentions=False,
    input_adapter='chatterbot.input.Gitter',
    output_adapter='chatterbot.output.Gitter'
)

trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train('chatterbot.corpus.english')

# The following loop will execute each time the user enters input
while True:
    try:
        response = chatbot.get_response('')

    # Press ctrl-c or ctrl-d on the keyboard to exit
    except (KeyboardInterrupt, EOFError, SystemExit):
        break
github gsingers / rtfmbot / src / python / run.py View on Github external
"chatterbot.adapters.logic.TimeLogicAdapter",
                    "chatterbot.adapters.logic.ClosestMeaningAdapter",
                    "adapters.SearchHubLogicAdapter"
                    ],
                  searchhub_host=config.get("SearchHub", "host"),
                  searchhub_port=config.get("SearchHub", "port"),
                  input_adapter="adapters.SlackPythonInputAdapter",
                  output_adapter="adapters.SlackPythonOutputAdapter",
                  database=storage + "/database.json",
                  slack_client=sc,
                  slack_channels=channel_names,
                  slack_output_channel=config.get("Slack", "output_channel"),
                  slack_bot_name=bot_name
                  )

chatbot.set_trainer(ChatterBotCorpusTrainer)
training_dir = "training"
files = [f for f in listdir(training_dir) if isfile(join(training_dir, f)) and f.endswith(".json") and f.find("example.json") == -1]
for file in files:
    print "Training on " + file
    chatbot.train("training." + file.replace(".json", ""))
# Train based on english greetings corpus
chatbot.train("chatterbot.corpus.english")

# Train based on the english conversations corpus
#chatbot.train("chatterbot.corpus.english.conversations")
print "Starting Chatbot"
while True:
    try:
        bot_input = chatbot.get_response(None)
    except(Exception):
        print "Exception"
github PantherHackers / PantherBot / scripts / talk.py View on Github external
def talk(response, args=[]):
    cb = ChatBot('PantherBot')
    cb.set_trainer(ChatterBotCorpusTrainer)
    cb.train(
    "chatterbot.corpus.english"
    )
    try:
        return [cb.get_response(" ".join(args)).text]
    except:
        return ["I'm feeling sick... come back later"]
github gunthercox / ChatterBot / examples / hipchat_bot.py View on Github external
'''
See the HipChat api documentation for how to get a user access token.
https://developer.atlassian.com/hipchat/guide/hipchat-rest-api/api-access-tokens
'''

chatbot = ChatBot(
    'HipChatBot',
    hipchat_host=HIPCHAT['HOST'],
    hipchat_room=HIPCHAT['ROOM'],
    hipchat_access_token=HIPCHAT['ACCESS_TOKEN'],
    input_adapter='chatterbot.input.HipChat',
    output_adapter='chatterbot.output.HipChat'
)

trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train('chatterbot.corpus.english')

# The following loop will execute each time the user enters input
while True:
    try:
        response = chatbot.get_response(None)

    # Press ctrl-c or ctrl-d on the keyboard to exit
    except (KeyboardInterrupt, EOFError, SystemExit):
        break
github gunthercox / ChatterBot / examples / training_example_chatterbot_corpus.py View on Github external
from chatterbot.trainers import ChatterBotCorpusTrainer
import logging


'''
This is an example showing how to train a chat bot using the
ChatterBot Corpus of conversation dialog.
'''

# Enable info level logging
logging.basicConfig(level=logging.INFO)

chatbot = ChatBot('Example Bot')

# Start by training our bot with the ChatterBot corpus data
trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train(
    'chatterbot.corpus.english'
)

# Now let's get a response to a greeting
response = chatbot.get_response('How are you doing today?')
print(response)
github gunthercox / ChatterBot / examples / export_example.py View on Github external
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

'''
This is an example showing how to create an export file from
an existing chat bot that can then be used to train other bots.
'''

chatbot = ChatBot('Export Example Bot')

# First, lets train our bot with some data
trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train('chatterbot.corpus.english')

# Now we can export the data to a file
trainer.export_for_training('./my_export.json')