C Introduction to Programmingcollege intro It is a fundament
C++ Introduction to Programming.[college intro]
It is a fundamental project and simple.
ELIZA is a \"virtual therapist\"; you type things to it and it asks you questions. Here\'s a sample transcript (from the web based ELIZA linked on the project page): ELIZA: Please tell me what\'s been bothering you. YOU: My family doesn\'t understand me ELIZA: Your family ? YOU: They think I\'m a horse. ELIZA: Do you know anyone else who is a horse ? YOU: I know lots of horses, I have no problem with horses. But I\'m not a horse. ELIZA: Do you say you know lots of horses for some special reason? YOU: I\'m just saying, I\'m not anti-horse. ELIZA: Is it because you are just saying that you came to me ? YOU: No, I came because of my family. ELIZA: Why not ? As you can see, ELIZA is not particularly intelligent; it basically works by pattern matching. It looks for certain keywords and symbols in the text the user enters, and then responds based on those. For example, if I enter YOU: My father hates me ELIZA: What else makes you think of your father? it responds to the keyword \"father\". However, if I enter YOU: My dog hates me. ELIZA: You say your dog hates you? it doesn\'t recognize what I said, so it just does a simple replacement, repeating what I said as a question, while changing \"my\"\' to \"your\" and \"me\" to \"you\". The core of ELIZA is Scanning the users input for keywords. (The original ELIZA would \"rank\" keywords so that a more-important keyword would be preferred to a less-important one, but you don\'t need to worry about that.) Replying, optionally transforming the user\'s input in some way. Which reply or transformation is used depends on the keyword: each keyword has its own reply or transformation that will be used. Although you could implement this using a big if-else chain to check for keywords and generate replies, you should think about ways to encode keywords and replies in data. For example, you might have a vector of keywords that are recognized, and then a parallel vector of replies. Search through the keyword vector for the first keyword found in the users input, and then get the corresponding reply. A more advanced usage might be to store in the reply vector, instead of just a literal string, a pattern, where parts of it could be replaced by parts of the user\'s input. (But start with something simple, and then work from there.) A good place to start for this project would be to write a function which reads a line and then splits it up into words, storing them in a vector. That will make it easier to look for keywords. You might also consider converting the input to lowercase, so you don\'t have to worry about uppercase letters.Solution
This question doesn\'t ask to code whole Eliza but to just read a line and break it into array of keywords in lowercase . Thats what this code will do:
#include<iostream>
 #include<vector>
 #include<sstream>
using namespace std;
 void split(string str, vector<string> &keys){
    //spliting string by space
   
    stringstream ss;
 ss.str(str);
 string item;//temporary storage
 while (getline(ss, item, \' \')) {
   
        for(int i=0;i<item.size();i++)
    {//checking for upper case
        if(item[i] <= \'Z\' && item[i] >= \'A\'){
            item[i] += 32;
            }
        }
       
        //pushing to keyword vector
        keys.push_back(item);
 }
   
 }
int main(){
    vector<string> keywords;
    string str;
   
    //scaning line from console
    getline(cin, str);  
   
    split(str, keywords);
       
    cout<<\"Keywords:\ \";
 for(int i=0;i<keywords.size();i++)
    cout<<keywords[i]<<endl;
return 0;
 }
![C++ Introduction to Programming.[college intro] It is a fundamental project and simple. ELIZA is a \ C++ Introduction to Programming.[college intro] It is a fundamental project and simple. ELIZA is a \](/WebImages/39/c-introduction-to-programmingcollege-intro-it-is-a-fundament-1119389-1761595324-0.webp)
![C++ Introduction to Programming.[college intro] It is a fundamental project and simple. ELIZA is a \ C++ Introduction to Programming.[college intro] It is a fundamental project and simple. ELIZA is a \](/WebImages/39/c-introduction-to-programmingcollege-intro-it-is-a-fundament-1119389-1761595324-1.webp)
