#Merlin is a command line program under the GPL license. I have completely re-written the askMerlin web scraping script since Google invalidated teh precious #algorithm, saying it violated their terms of service. # #This is released as GPL software. # # # Decision Analysis is a command line program that uses a weighted-average algorithm, and is used to decide between several # alternatives, using several criteria, with each criteria having a certain numerical "weight" or importance factor. Then, each # individual alternative is ranked for each criterion with a numerical score indicating its "performance" for that criterion. # # All scores and weights can be entered using a numerical ranking system. A convenient and easy to use ranking system might be 1 to # 100, where 100 represents the highest score, and 1 represents the lowest score. # # The General Decision option is the most general, with the user being prompted to enter all the data about a subject with which she # is presumably familiar. Thus the user is prompted to enter a list of options to be decided amongst; then a list of criteria to be # used in making the decision; then a list of weights for the various criteria; and finally a score for each option on each criterion. # This tool can be used to help clarify various alternatives in one's mind along with the criteria to be used to evaluate the options, # and their relative importance in the user's own mind. # # The same technique can be used as sort of an expert system for topics in which the programmer is relatively "expert", such as in the # basketball example and the scripts for choosing a general programming language and scripting language. For instance, the script to # choose a programming language compares many different languages for which the programmer has entered scores on various criteria, # such as "ease of use", "ease of learning", "speed of program execution", "cross platform capabilities" etc. etc. The user is # prompted to input the weighting or relative importance for each criterion, and then the program calculates the weighted average and # pronounces the highest scoring programming language to be the winner. # # I accept no culpability if the winner is often Python! # # The same algorithm is also adapted to making Yes or No type of decisions as illustrated in the code. I am sure the reader can easily # create many other versions of Decision Analysis fitting his or her own areas of expertise. I am also betting that the user can # create innovative variations on the logic and inner functioning of Decision Analysis. # # This is an easy script with which to play around with. enjoy! # # # # # #Call this the Version 1.0 ;-)))) # Original Program by Ron Stephens # Modified by Paul Winkler: # removed a lot of redundant stuff, # such as multiple identical function definitions; # replaced most calls to input() with get_number(); # fixed a few typos; # changed the format of scores from {('foo', 'bar'): 'baz'} # to {'foo': {'bar': 'baz'}} because it's flexible, at least as clear, # and takes many fewer keystrokes; # in general, replaced a lot of cut-n-paste duplication with loops. # There's still more that could be done, but I got sleepy. # I think the script reads at least as well this way, and # it's shorter by almost 25%. # Re-modified by Ron Stephens in 2003 print "A General Decision Analysis Program." print print "Have You Ever Had to Make Up Your Mind?" print import sys from urllib import * import re import regex import whrandom import string def get_number(prompt, lower=sys.maxint * -1, upper=sys.maxint): """ get_number(prompt) -> float This function prompts for a number. If the user enters bad input, such as 'cat' or '3l', it will prompt again. Now checks for upper and lower bounds. """ res = None while res is None: res = float(raw_input(prompt)) try: assert lower <= res <= upper except AssertionError: print "Value must be between", lower, \ "and", upper res = None except ValueError: pass return res def get_list(heading, prompt): print heading print print "(enter a blank line to end the list)" ret = [] i = 1 while 1: line = raw_input(prompt % i) if not line: break ret.append(line) i=i+1 print return ret def get_user_rankings(criteria): # Next, get the user to rank his criteria. I use a system where higher # is better, so that an undesirable characteristic can be given a negative # weight. # # {} is a dictionary, it can be indexed by (nearly) any expression, # and we will index it with the names of the criteria. rankings = {} print print "Enter relative importance of criteria (higher is more important)" print for c in criteria: rankings[c] = get_number("Criterion %s: " % c) return rankings def get_user_scores(options, criteria): # Next, get the user to score each option on all the criteria. # Scores are stored as a two-dimensional dictionary, like so: # {'option1': {'criteria1': 100, 'criteria2': 10}, # 'option2': {'criteria1': 50, 'criteria2': 10} # } scores = {} print print "Enter score for each option on each criterion" print for o in options: scores[o] = {} print print "Scores for option %s" % o print for c in criteria: scores[o][c] = get_number("Criterion %s: " % c) return scores def calculate_results(options, scores, rankings): # Calculate the resulting score for each option. This equation # is different from Rod Stephens' original program, because I # make more important criteria have higher rankings, and even let # bad criteria have negative rankings. # The "result" dictionary is indexed with the names of the options. result = {} # Criteria can be found automatically, doesn't need to be # passed as an argument. criteria = scores[options[0]].keys() for o in options: value = 0 for c in criteria: # print o, c, rankings[c], scores[o][c] value = value + rankings[c] * scores[o][c] result[o] = value return result def ranked_list(results): # Now, I want to take the dictionary result, and turn it into a ranked list results = results.items() # A list of tuples (key, value) results.sort(lambda x, y: -cmp(x[1], y[1])) # Sort the list using the reverse of the # "value" of the entry, so that higher # values come first return results def generic_decision_analyzer(options, criteria): pass def decisionanalysis(): # This code is covered by the GPL print print "This is a general decision program, and you can define your choices and criteria." print print "When prompted, please enter the options or choices that you need to decide amongst." print print "Then, when prompted, enter the criteria for making this decision." # First, ask the user to enter the lists options = get_list("Enter your options:", "Option %d: ") criteria = get_list("Now, enter your criteria:", "Criterion %d: ") print "A program to help you make decisions." rankings = get_user_rankings(criteria) scores = get_user_scores(options, criteria) results = ranked_list(calculate_results(options, scores, rankings)) print print "Results, in order from highest to lowest score" print print "%5s\t%s" % ("Score", "Option") print # Take the pairs out of results in order, and print them out for option, result in results: print "%5s\t%s" % (result, option) def YesNo(): print "Program to help you make a Yes or No decision." options = ["Yes", "No"] criteria = get_list("Enter your criteria ...", "Criterion %d: ") rankings = get_user_rankings(criteria) scores = get_user_scores(options, criteria ) print `scores` results = ranked_list(calculate_results(options, scores, rankings)) print print "The results are" print print "%5s %s" % ("Score", "Option") for option, result in results: print "%5s %s" % (result, option) if results[0] > results[1]: print "You should decide Yes!!!" else: print print "You should decide No!!!" print def lunch(): print "This is a classified, top secret program developed jointly by the CIA in cooperation with Merlin. Please keep it confidential" print "What should we do for lunch? ;-)))" criteria = ["taste", "convenience", "atmosphere", "value", "healthy"] options = get_list("Enter your restaurants or other food choices:", "Option %d: ") rankings = get_user_rankings(criteria) scores = get_user_scores(options, criteria) results = ranked_list(calculate_results(options, scores, rankings)) # Take the pairs out of results in order, and print them out for option, result in results: print "%5s\t%s" % (result, option) award = result winner = option for option,result in results: if result > award: award = result winner = option print "Let's all eat %s !!!" % winner class NLQ: def __init__(self, a_string): self.tuple = string.split(string.lower(a_string)) self.type = determine_type (self.tuple[0]) self.keywords = [] for word in self.tuple[1:]: if "~" in word: continue if "@" in word: continue if "#" in word: continue if "$" in word: continue if "%" in word: continue if "^" in word: continue if "&" in word: continue if "<" in word: continue if ">" in word: continue if ":" in word: continue if ";" in word: continue if "{" in word: continue if "}" in word: continue if "[" in word: continue if "*" in word: continue if "(" in word: continue if ")" in word: continue if "_" in word: continue if "-" in word: continue if "+" in word: continue if "=" in word: continue if "?" in word: continue if "for" == word: continue if word in IGNORE_WORDS: continue if word in OTHER_WORDS: continue if word in VERBS: continue if word in PRONOUNS: continue if "and" == word: continue if word[0] not in string.letters: continue if word[-1] not in string.letters: word = word[:-1] else: self.keywords.append (word) def __repr__(self): return "type: %s\nkeywords: %s" % (self.type, self.keywords) class multiChoiceGuesser: def __init__(self, question='', replys=()): self.question = question self.replys = replys def guessedAnswer(self): hits = [] result = [] for reply in self.replys: x = (self._getGoogleHits(self.question + ' ' + reply)) y = (self._getGoogleHits(reply)) x = float(x) y = float(y) if x == 0: x = x + 1 dividend = y / x hits.append(dividend) return hits.index(min(hits)) def _getGoogleHits(self, query): query = urlencode({'q':query}) urlHandle = urlopen ('http://www.google.com/search?%s' % query) googlePage = urlHandle.read() try: numberAsString = re.search( 'about', googlePage, re.S ).group(1) hits = re.sub(',', '',numberAsString) urlHandle.close() hits = int(hits) except: hits = 0 return hits def _getGoogleHits(self, query): query = urllib.urlencode({'q':query}) urlHandle = urllib.urlopen('http://www.google.com/search?%s' % query) googlePage = urlHandle.read() try: numberAsString = re.search( 'about', googlePage, re.S ).group(1) hits = re.sub (',', '',numberAsString) urlHandle.close() hits = int(hits) except: hits = 0 return hits def merlin(): #!/usr/bin/python #OK, I had to re-write askMerlin form scratch, due to Google's #disabling of the functionality that the program relied on. It # seesm that merlin was violating Google's terms of service, #unbeknownst to me, that's for sure! But I do not want to violate #anyone's terms of service, so I re-wrote askMerlin using # Yahoo instead. I also came up with a completely new #web-scraping algorithm, using string functions instead # of Regular Expressions. Simple is better than complicated! # # AskMerlin is a script I did by putting together two scripts and #modfying them both # and adding input/output routines around them. # # First, I ultilized the multiChoiceGuesser script that Max M posted # on the newsgroup comp.lang.python a couple weeks ago. This uses urllib #to go out to # the web and judge the appropriateness of a given answer by how many #hits it gets on Google # when coupled with the origninal question in a Google search. # My contributions were to enable the program to ask # for both an original question, and then for options to choose from. I #also set up a small # routine in order to choose a most appropriate answer, in the case that #no options are given. # This is done by using the second program, to create options of its own #to choose from # NLQ to pick out Keywords from the page returned by a Google search of #the question, by itself. # Then, these keyworsa are used as options or possible answers to the #question. # Then, multiChoiceGuesser is applied to the question along with all of #the Keywords # generated by NLQ. The result can take a long time, but eventually it #gets there, always. (???) # Also, I added to multiChoiceGuesser the requirement to do two google #searches, one on # the original question and each option, and one on the option by #itlself. Then # we calculate a ratio between each option's Google hit score and its #question/option # Google hit score, thus avoiding merely choosing the option that has #overwhelmingly high hits # all by itself. # # Surely better algorithms can vastly improve thsi program!!! # # I am hoping some one or some folks come up with improved variatiosn #and algorithtms # # Various algoritms could be tried, and then the results from the #various algoritms could be # averaged in order to produce more accurate results. # # # Currently, Merlin is may have a low IQ, but he has potential for the #future. # Anyway, Merlin can already answer just about any question. # Someday, perhaps he will even answer correctly or at least with #wisdom. most or all # of the time. # ;-))))))))))))) # # # NLQ: # a short program called NLQ, # or natural language query, which can be found online at #http://gurno.com/adam/nlq/#download # NLQ is a Class to take an inputted query and output 1. Keywords and 2. #also to categorize # the type of question being asked. I am primarily interested in using #the Keywords # extracted from a query by NLQ. I shamelesly modified NLQ to add many #more # IGNORE_WORDS and otherwise spruce it up. # # NLQ.py is still rather dumb, but hey, he has potential ;-))))). # stuff __version__ = "0.1" #definine the question types... UNKNOWN = 0 KNOWLEDGE = 1 COMPREHENSION = 2 APPLICATION = 3 ANALYSIS = 4 SYNTHESIS = 5 EVALUATION = 6 KNOWLEDGE_WORDS = ["name", "list", "recall", "define", "tell", "match", "who", "what", "when", "describe", "where"] COMPREHENSION_WORDS = ["retell"] APPLICATION_WORDS = ["why"] ANALYSIS_WORDS = ["how", "classify", "outline", "diagram"] SYNTHESIS_WORDS = [] EVALUATION_WORDS = [] PRONOUNS = ["he", "she", "it", "me", "you", "they", "them", "we", "who", "myself", "yourself", "ourself", "I", "me", "my"] VERBS = ["is", "was", "are", "were", "be", "shall", "am", "isn't", "can't", "won't", "shouldn't", "couldn't", "aren't", "do", "don't", ] OTHER_WORDS = ["if", "to", "too", "there", "will", "the", "a", "let", "I'll", "this", "these", "those", "let", "*.", "+*", ".*", "<*", ">*", "=*", "*=", "*<", "*>", "*.", "*-", "-*", "*:", ":*", ";*", "*;", "*,", ",*", "*.*", "*,*", "*;*", "*:*", "*+*", "*=*", "*-*", "*_*", "*<*", "*>*", "*?*", "*/*", "of", "and", "for", "very", "not", "in", "on", "up", "has", "from", "which", "and", "on", "of", "or", "not", "by", "can", "that", "your", "with", "their", "over", "back", "link", "about", "an", "at", "his", "enter", "into", "so", "was", "a", "as", "but"] IGNORE_WORDS = VERBS + PRONOUNS + OTHER_WORDS + KNOWLEDGE_WORDS + COMPREHENSION_WORDS + APPLICATION_WORDS + ANALYSIS_WORDS def determine_type (word): # for right now this only matches the first word. Soon it will # take the whole string and attempt to match using that. return_type = UNKNOWN if word in KNOWLEDGE_WORDS: return_type = KNOWLEDGE elif word in APPLICATION_WORDS: return_type = APPLICATION elif word in ANALYSIS_WORDS: return_type = ANALYSIS elif word in SYNTHESIS_WORDS: return_type = SYNTHESIS elif word in EVALUATION_WORDS: return_type = EVALUATION elif word in COMPREHENSION_WORDS: return_type = COMPREHENSION return return_type def guess(question, choices): mcg = multiChoiceGuesser(question, choices) print ' The question is: ', question print " Please wait for Merlin's answer: ", choices[mcg.guessedAnswer()] print '' def get_list(heading, prompt): print heading print print "(enter a blank line to end the list)" ret = [] i = 1 while 1: line = raw_input(prompt % i) if not line: break ret.append(line) i=i+1 print return ret question = raw_input ("What is your question?") if not question: redo() choices = get_list("Enter your suggested answers or options:", "Option %d: ") if choices == []: print """Since you did not give Merlin any options, it may take a while as he thinks. Please be patient; if you do not touch your keyboard or mouse for a few minutes, Merlin will respond ;-)))))""" urlHandle = urlopen('http://search.yahoo.com/bin/search?%s' % (question)) source = urlHandle.read() b = NLQ(source) choices = b.keywords u = NLQ(question) bad = u.keywords del choices[:1] del choices[-1:] guess(question, choices) while 1: question = raw_input ("what is your next question?") if not question: redo() choices = get_list("Enter your options:", "Option %d: ") if not choices: print """Since you did not give Merlin any options, it may take a while as he thinks. Please be patient and if you do not touch your keyboard or mouse for a few minutes, Merlin will respond.""" urlHandle = urlopen('http://search.yahoo.com/bin/search?%s' % (question)) source = urlHandle.read() b = NLQ(source) choices = b.keywords u = NLQ(question) bad = u.keywords del choices[:1] del choices[-1:] guess(question, choices) def talkToMerlin(): #---------------------------------------------------------------------- # therapist.py # # a cheezy little Eliza knock-off by Joe Strout # with some updates by Jeff Epler # last revised: 3/17/97 #---------------------------------------------------------------------- #---------------------------------------------------------------------- # translate: take a string, replace any words found in dict.keys() # with the corresponding dict.values() #---------------------------------------------------------------------- def translate(str,dict): words = string.split(string.lower(str)) keys = dict.keys(); for i in range(0,len(words)): if words[i] in keys: words[i] = dict[words[i]] return string.join(words) #---------------------------------------------------------------------- # respond: take a string, a set of regexps, and a corresponding # set of response lists; find a match, and return a randomly # chosen response from the corresponding list. #---------------------------------------------------------------------- def respond(str,keys,values): # find a match among keys for i in range(0,len(keys)): if keys[i].match(str) >= 0: # found a match ... stuff with corresponding value # chosen randomly from among the available options respnum = whrandom.randint(0,len(values[i])-1) resp = values[i][respnum] # we've got a response... stuff in reflected text where indicated pos = string.find(resp,'%') while pos > -1: num = string.atoi(resp[pos+1:pos+2]) resp = resp[:pos] + \ translate(keys[i].group(num),gReflections) + \ resp[pos+2:] pos = string.find(resp,'%') # fix munged punctuation at the end if resp[-2:] == '?.': resp = resp[:-2] + '.' if resp[-2:] == '??': resp = resp[:-2] + '?' return resp #---------------------------------------------------------------------- # gReflections, a translation table used to convert things you say # into things the computer says back, e.g. "I am" --> "you are" #---------------------------------------------------------------------- gReflections = { "am" : "are", "was" : "were", "i" : "you", "i'd" : "you would", "i've" : "you have", "i'll" : "you will", "my" : "your", "are" : "am", "you've": "I have", "you'll": "I will", "your" : "my", "yours" : "mine", "you" : "me", "me" : "you" } #---------------------------------------------------------------------- # gPats, the main response table. Each element of the list is a # two-element list; the first is a regexp, and the second is a # list of possible responses, with group-macros labelled as # %1, %2, etc. #---------------------------------------------------------------------- gPats = [ ["I need \(.*\)", [ "Why do you need %1?", "Would it really help you to get %1?", "Are you sure you need %1?"]], ["Why don't you \(.*\)", [ "Do you really think I don't %1?", "Perhaps eventually I will %1.", "Do you really want me to %1?"]], ["Why can't I \(.*\)", [ "Do you think you should be able to %1?", "If you could %1, what would you do?", "I don't know -- why can't you %1?", "Have you really tried?"]], ["I can't \(.*\)", [ "How do you know you can't %1?", "Perhaps you could %1 if you tried.", "What would it take for you to %1?"]], ["I am \(.*\)", [ "Did you come to me because you are %1?", "How long have you been %1?", "How do you feel about being %1?"]], ["I'm \(.*\)", [ "How does being %1 make you feel?", "Do you enjoy being %1?", "Why do you tell me you're %1?", "Why do you think you're %1?"]], ["Are you \(.*\)", [ "Why does it matter whether I am %1?", "Would you prefer it if I were not %1?", "Perhaps you believe I am %1.", "I may be %1 -- what do you think?"]], ["What \(.*\)", [ "Why do you ask?", "How would an answer to that help you?", "What do you think?"]], ["How \(.*\)", [ "How do you suppose?", "Perhaps you can answer your own question.", "What is it you're really asking?"]], ["Because \(.*\)", [ "Is that the real reason?", "What other reasons come to mind?", "Does that reason apply to anything else?", "If %1, what else must be true?"]], ["\(.*\) sorry \(.*\)", [ "There are many times when no apology is needed.", "What feelings do you have when you apologize?"]], ["Hello\(.*\)", [ "Hello... I'm glad you could drop by today.", "Hi there... how are you today?", "Hello, how are you feeling today?"]], ["I think \(.*\)", [ "Do you doubt %1?", "Do you really think so?", "But you're not sure %1?"]], ["\(.*\) friend\(.*\)", [ "Tell me more about your friends.", "When you think of a friend, what comes to mind?", "Why don't you tell me about a childhood friend?"]], ["Yes", [ "You seem quite sure.", "OK, but can you elaborate a bit?"]], ["\(.*\) computer\(.*\)", [ "Are you really talking about me?", "Does it seem strange to talk to a computer?", "How do computers make you feel?", "Do you feel threatened by computers?"]], ["Is it \(.*\)", [ "Do you think it is %1?", "Perhaps it's %1 -- what do you think?", "If it were %1, what would you do?", "It could well be that %1."]], ["It is \(.*\)", [ "You seem very certain.", "If I told you that it probably isn't %1, what would you feel?"]], ["Can you \(.*\)", [ "What makes you think I can't %1?", "If I could %1, then what?", "Why do you ask if I can %1?"]], ["Can I \(.*\)", [ "Perhaps you don't want to %1.", "Do you want to be able to %1?", "If you could %1, would you?"]], ["You are \(.*\)", [ "Why do you think I am %1?", "Does it please you to think that I'm %1?", "Perhaps you would like me to be %1.", "Perhaps you're really talking about yourself?"]], ["You're \(.*\)", [ "Why do you say I am %1?", "Why do you think I am %1?", "Are we talking about you, or me?"]], ["I don't \(.*\)", [ "Don't you really %1?", "Why don't you %1?", "Do you want to %1?"]], ["I feel \(.*\)", [ "Good, tell me more about these feelings.", "Do you often feel %1?", "When do you usually feel %1?", "When you feel %1, what do you do?"]], ["I have \(.*\)", [ "Why do you tell me that you've %1?", "Have you really %1?", "Now that you have %1, what will you do next?"]], ["I would \(.*\)", [ "Could you explain why you would %1?", "Why would you %1?", "Who else knows that you would %1?"]], ["Is there \(.*\)", [ "Do you think there is %1?", "It's likely that there is %1.", "Would you like there to be %1?"]], ["My \(.*\)", [ "I see, your %1.", "Why do you say that your %1?", "When your %1, how do you feel?"]], ["You \(.*\)", [ "We should be discussing you, not me.", "Why do you say that about me?", "Why do you care whether I %1?"]], ["Why \(.*\)", [ "Why don't you tell me the reason why %1?", "Why do you think %1?" ]], ["I want \(.*\)", [ "What would it mean to you if you got %1?", "Why do you want %1?", "What would you do if you got %1?", "If you got %1, then what would you do?"]], ["\(.*\) mother\(.*\)", [ "Tell me more about your mother.", "What was your relationship with your mother like?", "How do you feel about your mother?", "How does this relate to your feelings today?", "Good family relations are important."]], ["\(.*\) father\(.*\)", [ "Tell me more about your father.", "How did your father make you feel?", "How do you feel about your father?", "Does your relationship with your father relate to your feelings today?", "Do you have trouble showing affection with your family?"]], ["\(.*\) child\(.*\)", [ "Did you have close friends as a child?", "What is your favorite childhood memory?", "Do you remember any dreams or nightmares from childhood?", "Did the other children sometimes tease you?", "How do you think your childhood experiences relate to your feelings today?"]], ["\(.*\)\?", [ "Why do you ask that?", "Please consider whether you can answer your own question.", "Perhaps the answer lies within yourself?", "Why don't you tell me?"]], ["quit", [ "Thank you for talking with me.", "Good-bye.", "Thank you, that will be $150. Have a good day!"]], ["\(.*\)", [ "Please tell me more.", "Let's change focus a bit... Tell me about your family.", "Can you elaborate on that?", "Why do you say that %1?", "I see.", "Very interesting.", "%1.", "I see. And what does that tell you?", "How does that make you feel?", "How do you feel when you say that?"]] ] #---------------------------------------------------------------------- # Main program #---------------------------------------------------------------------- gKeys = map(lambda x:regex.compile(x[0]),gPats) gValues = map(lambda x:x[1],gPats) print "merlin, at your service!" print "Talk to me by typing in plain English, using normal upper-" print 'and lower-case letters and punctuation. Enter "quit" when done.' print '='*72 print "Hello. How are you feeling today?" s = "" while s != "quit": try: s = raw_input(">") except EOFError: s = "quit" print s while s[-1] in "!.": s = s[:-1] print respond(s,gKeys,gValues) def redo(): tidy = 1 while 1: # loop forever tidy = tidy + 1 if tidy > 2: againornot = raw_input ("Hit 'enter' to ask another question, or type 'quit' to quit this program") if againornot == "quit": break print "Please enter the number for the type of interaction you wish to have with Merlin:\n" print "1. Ask Merlin any questions you want, tap into the wisdom of the web (requires internet conncection)\n" print "2. General Decision Analysis, you choose the options, criteria, etc.\n" print "3. Talk to Merlin about anything\n" print "4. What should we do for lunch???\n" print "5. Questions with Yes or No type answers\n" print "6. Type '8' or 'quit' to quit this program\n" choice = get_number("Please type in the number of the type of decision-program you wish to run from above and hit enter:", 1, 6) if choice ==1: merlin() elif choice ==2: decisionanalysis() elif choice ==3: talkToMerlin() elif choice ==4: lunch() elif choice ==5: YesNo() elif choice ==6: break # break from infinite loop elif choice =="quit": break # exit from infinite loop else: print "Invalid operation" ###### MAIN LOOP ############ tidy = 1 while 1: # loop forever tidy = tidy + 1 if tidy > 2: againornot = raw_input("Hit 'enter' to ask another question, or type 'quit' to quit this program") if againornot == "quit": break print "Please enter the number for the type of interaction you wish to have with Merlin:\n" print "1. Ask Merlin any questions you want, tap into the wisdom of the web (requires internet conncection)\n" print "2. General Decision Analysis, you choose the options, criteria, etc.\n" print "3. Talk to Merlin about anything\n" print "4. What should we do for lunch???\n" print "5. Questions with Yes or No type answers\n" print "6. Type '8' or 'quit' to quit this program\n" choice = get_number("Please type in the number of the type of decision-program you wish to run from above and hit enter:", 1, 6) if choice ==1: merlin() elif choice ==2: decisionanalysis() elif choice ==3: talkToMerlin() elif choice ==4: lunch() elif choice ==5: YesNo() elif choice ==6: break # break from infinite loop elif choice =="quit": break # exit from infinite loop else: print "Invalid operation"