Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

\"Conversations often shift focus to earlier topics. Modify the therapist progra

ID: 3535408 • Letter: #

Question

"Conversations often shift focus to earlier topics. Modify the

therapist program to support this capability. Add each patient

input to a history list. Then, ocassionally choose an element at

random from this list, change persons, and ammend the qualifier

"Earlier you said that." to this reply. Make sure that this option

is triggered only after several exchanges have occurred.


I have added the qualifier, but am not sure how to write the

list of responses, or modify the probabilty of the single qualifier

"Earlier you said that."


here is the program:


import random

hedges = ("Please tell me more.",
"Many of my patients tell me the same thing.",
"Please continue.")

qualifiers = ("Why do you say that?",
"What makes you think that?",
"Can you explain why?", "Earlier you said that.")

replacements = {"I":"you", "me":"you", "my":"your",
"we":"you", "us":"you", "mine":"yours"}

patients = {}


def reply(sentence):
"""Builds and returns a reply to the sentence."""
probability = random.randint(1, 4)
if probability == 1:
return random.choice(hedges)
else:
return random.choice(qualifiers) + changePerson(sentence)

def changePerson(sentence):
"""Replaces the first person pronouns with
second person pronouns."""
words = sentence.split()
replyWords = []
return " ".join(replyWords)

def addPatient(patientName):
"""Adds a patient's name to a list."""
patients = {}
patients[Name] = User(Name)
for Name in patients:
if patientName == patients:
break
else:
print(patients.append(Name))

def main():
"""Handles the interaction between patient and doctor."""
print("Hello, I hope you are doing well.")
print("May I ask your name?")
patients = input("enter your name: ")
print("How can I help you today,", patients, "?")

while True:
sentence = input(" >>")
if sentence.upper() == "QUIT":
print("Have a nice day!")
break
print(reply(sentence))

main()



Explanation / Answer


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote