#include #include #include #include #include #include "reflex.h" int main() { vector reflexes; const string a1[] = { "Is it because you are > that you came to me?", "How long have you been > ?", "Do you believe it is normal to be > ?", "Do you enjoy being > ?" }; const size_t n1 = sizeof a1 / sizeof a1[0]; reflexes.push_back(reflex("I am", a1, a1 + n1)); const string a2[] = { "Why are you interested in whether I am > or not?", "Would you prefer if I weren't > ?", "Perhaps I am > in your fantasies.", "Do you sometimes think I am > ?" }; const size_t n2 = sizeof a2 / sizeof a2[0]; reflexes.push_back(reflex("Are you", a2, a2 + n2)); const string a3[] = { "I'm not interested in names.", "I don't care about names. Please continue." }; const size_t n3 = sizeof a3 / sizeof a3[0]; reflexes.push_back(reflex("name", a3, a3 + n3)); //If ELIZA doesn't recognize any word the user said, const string a4[] = { "I am not sure I understand you fully.", "Please go on.", "What does that suggest to you?", "Do you feel strongly about discussing such things?" }; const size_t n4 = sizeof a4 / sizeof a4[0]; reflexes.push_back(reflex("", a4, a4 + n4)); cout << "How do you do. Please tell me your problem.\n" << "Type no punctuation except apostrophes.\n" << "Press RETURN at the end of each sentence.\n\n"; string input_line; while (getline(cin, input_line) && input_line != "quit") { vector words = reflex::chop(input_line); for (vector::iterator it = reflexes.begin(); it != reflexes.end(); ++it) { const string reply = (*it)(words); if (reply != "") { cout << reply << "\n\n"; break; } } } cout << "Goodbye.\n"; return EXIT_SUCCESS; }