#!/usr/bin/env python # # Good site: http://german.about.com/library/blcase_sum.htm # translating from english to german # e.g. Accusative a good book # should return ein gutes Buch # Accusative a good man # should return einen guten Mann # Data flow is this: take English and find gender, number and gloss of noun. # Use that plus the case to get article and adjective. # Combine together. import random output = "Tell me what you're feeling (when you want to stop, " output = output + "type the word stop):\n " allreplies = ["Patient replies\n"] flag = 1 friendname = "lkajoieare" # a non-name lastoutput = "kjlkjlk" friendnamecoming = 0 havefriendname = 0 while flag == 1: if(lastoutput == output): output = "Please go on.\n" inpatient = raw_input (output) lastoutput = output allreplies.append(output[0:len(output)-1]) allreplies.append(inpatient) allreplies.append(" ========== ") mywords = inpatient.split(" ") if (len(mywords) == 1) & (friendnamecoming == 1): havefriendname = 1 friendname = mywords[0] x = random.random() if x < 0.3: output = "Interesting. What else?\n" elif x < 0.5: output = "I'm listening.\n" elif havefriendname == 0: if (2 < len(mywords))&(("I" == mywords[0])|("i" == mywords[0])): output = "You?\n" else: output = "Tell me more\n" else: output = ("Tell me more about ") + friendname + (".\n") if ("stop" in mywords) & (len(mywords) == 1): flag = 0 print "Ok. Thanks and take care" elif ("father" in mywords) | ("dad" in mywords): if x > 0.6: output = "Tell me more about your father.\n " else: output = "What do you feel about your father.\n " elif (friendname in mywords): if x > 0.5: output = ("Speak to me about ") + friendname + (".\n") else: output = ("What would ") + friendname + (" think about that?\n") elif ("violence" in mywords) | ("violent" in mywords): if x > 0.6: output = "Why would anyone want to be violent?\n" else: output = "Are you interested in guns?\n" elif (("strangle") in mywords) | (("kill") in mywords): output = "Why these feelings?\n" for line in allreplies: print line