gunthercox / ChatterBot

ChatterBot is a machine learning, conversational dialog engine for creating chat bots
https://chatterbot.readthedocs.io
BSD 3-Clause "New" or "Revised" License
14.07k stars 4.44k forks source link

Train Chatterbot on input #1293

Open GMT95 opened 6 years ago

GMT95 commented 6 years ago

hi, i want to do something like this

Me: what is the color of sky? bot: I dont know, can you tell me. Me: blue

and the bot saves the "blue" output on "what is the color of sky input".

Currently the bot saves my input "what is the color of sky?"

Please help.

vkosuri commented 6 years ago

@GMT95 chatterbot treas first statement and second as response. in your case

statement-1
response-1
....
....
statement-n
response-n

But you are trying in different fashion, for your use case it should be like this, Very good documentation on training process found here http://chatterbot.readthedocs.io/en/stable/training.html

-- what is the color of sky
-- blue

See Low confidence response selection filter out your responses with below confidence. http://chatterbot.readthedocs.io/en/stable/logic/index.html#low-confidence-response-adapter

GMT95 commented 6 years ago

Thankyou @vkosuri, i have no problem training with corpus data or custom training file. I just wanted to ask that if I can train chatterbot while having a conversation with it.

For Example if chatterbot doesn't know something it says:

I dont know this can you tell me

and when i reply with the answer,chatterbot saves it in the database.

Me: what is the color of sky? bot: I dont know, can you tell me. Me: blue

and when i ask chatterbot again What is the color of sky? it replies with blue

Is it possible to do something like this?

vkosuri commented 6 years ago

yes, try this example https://github.com/gunthercox/ChatterBot/blob/master/examples/learning_new_response.py

GMT95 commented 6 years ago

Thankyou @vkosuri, the last link is really helpful.

GMT95 commented 6 years ago

@vkosuri can i set a default response when something is not in Chatterbot's Knowledge like

Bot replies: I don't know or Can you please tell me

vkosuri commented 6 years ago

Yes

gunthercox commented 6 years ago

It sounds like this question has been answered? @GMT95 I'm going to close this ticket off for now, feel free to reopen it if your original question wasn't resolved.

AfrahAsif commented 5 years ago

yes, try this example https://github.com/gunthercox/ChatterBot/blob/master/examples/learning_new_response.py

This link is not working.. How can I solve the same issue raised by @GMT95 ?

vkosuri commented 5 years ago

It's has been very long, I understood @GMT95 question, The Statements are sent through the console and the training process start on the fly, Bot return response

If that is the case I think this is not available right now.

gunthercox commented 5 years ago

@AfrahAsif See this example instead: https://github.com/gunthercox/ChatterBot/blob/master/examples/learning_feedback_example.py

Augus2411 commented 5 years ago

@gunthercox Im also trying what @GMT95 and @AfrahAsif is trying can you help me how to implement it to the one im working on?

from chatterbot import ChatBot from chatterbot.trainers import ListTrainer

def get_response(usrText): bot = ChatBot('Bot', storage_adapter='chatterbot.storage.SQLStorageAdapter', logic_adapters=[ { 'import_path': 'chatterbot.logic.BestMatch' }, { 'import_path': 'chatterbot.logic.LowConfidenceAdapter', 'threshold': 0.70, 'default_response': 'I am sorry, but I do not understand.' } ], trainer='chatterbot.trainers.ListTrainer') bot.set_trainer(ListTrainer) while True: if usrText.strip()!= 'Bye': result = bot.get_response(usrText)
reply = str(result) return('Bot :'+reply) if usrText.strip() == 'Bye': return('Bot :'+reply) break

from chatterbot import ChatBot from chatterbot.trainers import ListTrainer import os

def setup(): chatbot = ChatBot( 'Bot', storage_adapter='chatterbot.storage.SQLStorageAdapter', trainer='chatterbot.trainers.ListTrainer') for file in os.listdir('C:/Users/hp/Chatbot/data/'): convData = open(r'C:/Users/hp/Chatbot/data/' + file,encoding='latin-1').readlines()

trainer = ListTrainer(chatbot)

    chatbot.set_trainer(ListTrainer)
    chatbot.train(convData)
    #print("Training completed")

setup()

Augus2411 commented 5 years ago

@gunthercox also im having this kind of error Type something to begin... hi Traceback (most recent call last): File "feed.py", line 41, in input_statement TypeError: generate_response() missing 1 required positional argument: 'conversation_id'

Augus2411 commented 5 years ago

@vkosuri can you help me with this sir?

gunthercox commented 5 years ago

@Augus2411 It looks like the code you are using is from an older version of ChatterBot. I would suggest that you look over the latest version of the examples.