Monday, February 13, 2017

Eliza Python

Tags

ELIZA is an early natural language processing computer program created from 1964 to 1966[1] at the MIT Artificial Intelligence Laboratory by Joseph Weizenbaum.[2] Created to demonstrate the superficiality of communication between man and machine.

Code::         #a short example u can increase the conditions 

def reply(line,words):
    if len(words)==0: return "You have to talk to me "
    elif "mother"in words:return "Tell me more about your mother "
    elif "father" in words :return "Tell me more about your father "
    elif words[0]=='i' and words[1]=='feel': return "Why do you feel that way? "
    elif words[-1]=='?': return "What do u want to know? "
    elif words[0]=='i' and words[1]=='think': return "Do you really think so? "
    elif "question" in words:return "What's the question? "
    elif "love" in words:return "I must tell you,Love is Very Complicated Agree? "
    elif "agree" in words:return "Do you agree always with this much ease? "
    elif "no" in words: return"Nice!!,Tell me more "
    else: return "Tell me more "

name=input("Hello, Welcome to NT Therapy Center,What's Your name? ")
print("Type quit to exit")
line=input("Hello "+name+" How can we help you? ")
while line!='quit':
    line=line.lower()
    words=line.split()
    replied=reply(line,words)

    line=input(replied)

Output::