Question: In the 1960s, computer scientist Joseph Weizenbaum wrote a computer program named ELIZA that parodied a conversation with a psychotherapist. ELIZA responded, using scripted replies,

 In the 1960s, computer scientist Joseph Weizenbaum wrote a computer program

In the 1960s, computer scientist Joseph Weizenbaum wrote a computer program named ELIZA that parodied a conversation with a psychotherapist. ELIZA responded, using scripted replies, to simple sentences typed in by the user. For this program, we will implement a very basic Python version of the ELIZA program. 1. Start by defining a function named longeatword(). This function takes a string as its argument, representing a sentence with one or more words. The function returns the longest single word in the input (if multiple words share the same greatest length, then the first one to occur in the sentence is returned). You may assume that the input does not contain any punctuation, and that the words in the input are all separated by spaces (Hint: use the aplit) function here). Once you have your list of individual words, use a loop to find the longest word. Here is some helpful pseudocode Set longest to 0 (the index of the longest word seen so far) Set i to 1 While i is less than the length of the ist: If the length of list is greater than the length of listllongest Set longest to i Add 1 to the vaue of i At the end of the loop, longest will hold the index of the longest word in the list. 2. Next, define a function named noxtReapon. This function takes a single argument, representing a single word. The function returns a new string based on the length of the input word. This string represents the next question to be asked by the program. Suppose that the input word is X. If the word is exactly 4 characters long, return the string (with an appropriate substitution for X)Tell me more about X.. the word is exactly 5 characters long, the response should be, "Why do you think X is important?" If the word is 6 or more characters long, the response should be "Now we are getting somewhere. How does X afiect you the most?" If the word's length is 3 or less, the response should be "Maybe we should move on. Is there something else you would like to talk about? 3. Finally, at the bottom of your source code file, write the main logic for your program, which will call the functions you defined in the previous steps. Your program should start by asking Stony Brook University CSE 101: Introduction to Computers (Section 01) Fall 2017 the user "What would you like to talk about? Until the user types "Goodbye" (with that exact capitalization), your program should enter a loop where it processes the user input, prints an appropriate response, and then reads in a new response from the user If the user response contains the lowercase word "you" (or any word that includes the lowercase character sequence "you"), the program should print out Im not important Let's talk about you instead. as its next prompt. Otherwise, find the longest word in the user's response and call nextReaponse) to get the next input prompt Once the user types "Goodbye", your program should print a farewell message and end. A pseudocode algorithm would look something like the following: prompt what would you like to talk about?" answer user input via put) and the prompt variable while answer does not equal "Goodbye if answer contains "you". prompt "I'm not important. Let's talk about you instead." else word longest word in answer prompt next response based on longest word Read in a new value for answer via inputo and the prompt variable Save and test your code. Test it out with a briet conversation to make sure that it seems to be working properly, and fix any bugs that you may find. Note that this is an extremely simplistic mplementation of ELIZA, and so its responses will often border on the strange, if not outright bizarre Sample Program Execution (program output is in italics, and user input is bold) What would you like to talk about?i like cse 101 Tel me more about like like means to enjoy something Now we are getting somewhere. How does something affect you the most? what do you mean I'm not important. Lets taik about you instead. what is it TeW me more about what Goodbye

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!