So I know a lot of general C++ code but I'm still, by most standards, a novice. My dream is to write a chatbot. With nothing to work on in programming class recently, I started brainstorming different methods of writing a chatbot. I came up with the idea of giving it a few very basic if statements to output strings depending on the user's input. Obviously, this won't make for a very advanced chatbot, so I thought of talking to the chatbot for hours and adding an if statement every time I want it to respond to new input I come up with, so after several hours of this it will have hundreds of if statements which allow it to function on a more advanced level. But this sounds pretty inefficient and time-consuming. Would there be a way to allow the chatbot to tell the user every time it doesn't understand input and then ask what the appropriate response would be and add an if statement to its own code?
Also, other information, whether related to self-modifying code or not, pertaining to programming chatbots in C++ (like how to program case-based reasoning) would be greatly appreciated. I just need somewhere to start.
generally from what i know, chatbots consists of a long list of if-else statements. if user says this, then this, etc etc.
Would there be a way to allow the chatbot to tell the user every time it doesn't understand input and then ask what the appropriate response would be and add an if statement to its own code?
this can be done with an else statement. so if what the user inputs is not in the list of if-else, it will fall into else, which is a general answer. usually, chatbots are designed to say "i'm sorry, i don't understand etc etc, can you make your question more clear etc etc?"
as for the ability to add an if statement on its own, i know its possible, but not in my knowledge field. hope this helps.
C++ is not a self-reflexive programming language. Some languages can change the code of a program they are programmed in themselves, but C++ can not.
There is a workaround, though. Store (in a separate file) a list of possible inputs and outputs that are directly related to each other in some way, and when your chatbot doesn't know what to say to a user's input, have it append that input and the appropriate response to the file. I would be very wary of putting a chatbot out there, though, with learning ability, because some users will teach it to use cuss words and whatnot based on innocent input. For example, some malicious users may teach it to say something derogatory or negative to any user that enters the chat room or any person that says 'Hello!'.