Finding keywords in Cin and Cout
Hello, I am writing an AI program similar to a chatterbot. I want it to be able to detect user inputted words. The user will input messages through 'cin' statements where they will then be interpreted. For example, if I inputted the message "I like waffles", I would want the program to search and detect the strings "like" and "waffles" and make a meaningful response. I originally intended to use the find() function to detect strings inside user inputted statements but I am not sure how to do this. Can anyone help me with this?
Re: Finding keywords in Cin and Cout
If you plan to allow the input to something complicated consider using something like flex http://flex.sourceforge.net/ for the parsing.
Re: Finding keywords in Cin and Cout
I don't need something that complicated at the moment although it will be useful in the future. What I want right now is for the computer to search for strings found within user inputted cin statements.
Re: Finding keywords in Cin and Cout
Or, if you want a more hands-on or classical/vintage approach as a starting point, you may want to have a look at ELIZA.
However, I remember claimed quotes from Weizenbaum that, while most people perceived ELIZA as a startling example of AI, he actually wrote it to disprove the possibility of AI. There's no reference to that in the Wikipedia article, though, but there may be one behind the citation links (didn't check them). ... or it's just one more of these funny urban legends... :D
Re: Finding keywords in Cin and Cout
You can use strtok to break a NULL terminated string into individual words, but then what? Have you thought your approach out yet? Getting individual words in strings is the easiest part of the problem.
Re: Finding keywords in Cin and Cout
With all do respect, but if you don't know how to manipulate a string, then don't try to make something hard. Instead, start learning how to code.