Question

In: Computer Science

Problem #1: A sequence of inquiry ELIZA:How are you feeling? USER:I am angry. ELIZA:Why are you...

Problem #1: A sequence of inquiry

                                ELIZA:How are you feeling?
                                USER:I am angry.
                                ELIZA:Why are you angry?
                                USER:I am angry because I am tired.
                                ELIZA:Why are you tired?
                                USER:I am tired because I am staying up late looking at facebook.
                                ELIZA:Are you angry because you are staying up late looking at facebook?

Write an ELIZA-type program.

Include asking three questions and make a deduction based on user input.

Use a series of nested if statements to create this program.

You do not need to duplicate the example below exactly, you just need to make three exchanges between the user and ELIZA using "If" statements and other techniques covered in class such as the Regex library and string recognition.

For Example:

Include a response for not understanding the user's input.

Solutions

Expert Solution

Eliza is an AI Program that simulates the behavior of a therapist. ELIZA worked by applying pattern-matching rules. It looked for a rule whose left side matched the last sentence entered by the user, then used the right side of that rule to generate a response.

It's easy to start Eliza! Just type "./eliza.pl" or "perl eliza.pl" in the command line and you can enjoy chatting with Eliza.

If you want to quit Eliza, type "goodbye/done/exit/quit/bye"

For example

Eliza : Hello, I'm Eliza.

User : hello, I’m Mr X.

Eliza: What's your name?

User : I’m Mr X

Eliza: Nice to meet you, How are you?

User:I’m fine dear.

Eliza: Goodbye.

User: Bye.

The program in C++

#include<iostream.h>

#include<conio.h>

void resp :: display_resp(int num)

{

cout<<"ELIZA > ";

for(int i=0;i<strlen(replys[num]);i++)

{

     // for deliberate typing errors

     // (for simulating the human behavoir ;-)

     if(RanNum(6)==0)

     {

     char c=RanNum(100);

     if(c=='\n' || c=='\b' || c==13)

          cout<<"w";

     else

          cout<<c;

     delay(RanNum(DELAY));

     // correcting the deliberate typing error

     cout<<"\b";

}

// * is used to write anything after the // keyword

// as it is, but with some transformatio // ns like

// converting MY to YOUR.< // br> if(replys[num][i]=='*')

{

     char * s1=ip.userip+strlen(ip.keyword);

     short int flag=0;

     for(int m=0;m<TRANSPOSE;m++)

          {

          char * s2=wordin[m];

          char *ptr=NULL;

          ptr=strstr(s1,s2);

          if(ptr!=NULL)

          {

          // transposition word found in the

          // user input

          flag=1;

          // printing text before wordin[m]

          int times=ptr-s1;

          for(int i=0;i<times;i++)

          {

          delay(DELAY);

          cout<<ip.userip[strlen(ip.keyword)+i];

          }

          // printing the wordout

          cout<<wordout[m];

          // printing the left overs

          char c;

          c=*(ptr+strlen(wordin[m]));

          int t=0;

          while(c!='\0')

          {

          cout<<*(ptr+strlen(wordin[m])+t);

          t++;

          c=*(ptr+strlen(wordin[m])+t);

          }

          }

          } // end of for

     // if flag is still zero , this means no need for

     // transposing any word.

     if(0==flag)

     {

          char c;

          c=*(s1+strlen(ip.keyword));

          int t=0;

          while(c!='\0')

          {

          cout<<*(s1+t);

          t++;

          c=*(s1+t);

     }

} // end of if

break;

}

else

{

cout<<replys[num][i];

delay(RanNum(DELAY));

}

} // end of for

// giving the prompt back to user

cout<<"\n"<<user<<" > ";

}


Related Solutions

can you make me a sample problem of 2 geometric sequence, harmonic sequence, arithmetic sequence so...
can you make me a sample problem of 2 geometric sequence, harmonic sequence, arithmetic sequence so that's all 5 this is for Grade 10 Mathematics all with answers and solutions thankyou
Problem 1: Discover the rule where a sequence of three number operates on. Problem 2 (code...
Problem 1: Discover the rule where a sequence of three number operates on. Problem 2 (code braking problem): Discover the rule of when the box opens. Assignment: Give a discussion of the two problems and how it was solved. What made each problem difficult and how it relates to the Gestalt psychology discussed in class
Problem 1: Discover the rule where a sequence of three number operates on. Problem 2 (code...
Problem 1: Discover the rule where a sequence of three number operates on. Problem 2 (code braking problem): Discover the rule of when the box opens. Assignment: Give a discussion of the two problems and how it was solved. What made each problem difficult and how it relates to the Gestalt psychology discussed in class
I am working on this problem for the company AT & T and am not sure...
I am working on this problem for the company AT & T and am not sure how to start it. Draw a chart of the main inter-organizational linkage mechanisms (e.g., long -term contacts, strategic alliances, mergers) that your organization uses to manage its symbiotic resource interdependencies. Using resource dependence theory and transaction cost theory, discuss why the organization to manage its interdependencies in this way. Do you think the organization has selected the most appropriate linkage mechanisms? Why or why...
1. How would eating polysaccharides relieve symptoms of feeling weak, lacking energy, and feeling thirty. The...
1. How would eating polysaccharides relieve symptoms of feeling weak, lacking energy, and feeling thirty. The patient went on a diet low in carbohydrates and calories and high in protein and fats. 2. Definite homeostasis and negative feedback. Explain significance of homeostasis in physiology and medicine using specific examples from the case of the patient in question 1.
I am stuck on this problem and I am not sure what the solution is. In...
I am stuck on this problem and I am not sure what the solution is. In C Write item.h and item.c. In item.h, typedef a struct (of type t_item) which contains the following information: t_item: char name[MAX_ITEM_NAME_STRING]; char description[MAX_ITEM_DESCRIPTION_STRING]; Make sure that MAX_ITEM_NAME_STRING and MAX_ITEM_DESCRIPTION_STRING are defined with suitable sizes in your item.h. Typical values are, 25 and 80, respectively. Add the following interface definition to item.h: int item_load_items(t_item items[], int max_items, char *filename); Returns the number of objects loaded...
Problem Statement You have the mRNA sequence that results from the transcription of the Homo sapiens...
Problem Statement You have the mRNA sequence that results from the transcription of the Homo sapiens Hemoglobin subunit beta gene. Knowing that the 5' and 3' ends of the mRNA are processed post-transcriptionally, you know that the start codon and termination codon lie somewhere inside the sequence. A manual inspection of the mRNA sequence should reveal the locations of the start and stop codons, but to ensure you don't miss anything you decide to write a Python script to analyze...
Female employees report that their male coworkers tend to offer solutions without much problem inquiry. Do...
Female employees report that their male coworkers tend to offer solutions without much problem inquiry. Do you think this is an accurate observation? Explain your point of view in 150 to 200 words.
1) A morbid inquiry: Which is greater – the number of people alive in the world...
1) A morbid inquiry: Which is greater – the number of people alive in the world at this moment or the number of people that have died in all of history? Think about how integration is part of the analysis to this question. Also consider that the total human population of the earth is accurately estimated for all of recorded history – let this function be P (t) a) Use an integral to define a function Q (t) that expresses...
Critical Thinking 1: The diamond-water paradox In “An Inquiry into the Nature and Causes of the...
Critical Thinking 1: The diamond-water paradox In “An Inquiry into the Nature and Causes of the Wealth of Nations” published in 1776, Adam Smith wrote: “Nothing is more useful than water: but it will purchase scarcely anything… A diamond, on the contrary, has scarcely any use-value; but a very great quantity of other goods may frequently be had in exchange for it” Explain the diamond-water paradox and find out in the literature how economists have later solved this paradox.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT