def startTourGuide(): stan_parse = parse.syntaxParser() time.sleep(3) print "How can I help you?\n" while(1): text = raw_input("--> ") if text == "end": return if text == "" or text == "\n": continue leia.leia(text, planner=plan.planManager(), lexicon=knowledge.lexicon_alexnut.Lexicon(), sp=stan_parse)
### the world is reset at every iteration world = [['_' for i in range(world_length)] for j in range(world_length)] ### then the user is placed world[position[0]][position[1]] = '*' ### TODO: and whatever known locations there are on the map pprint(world) input = raw_input("::") ### clear screen os.system(['clear','cls'][os.name == 'nt']) ### move the user if input in direction.keys(): position[direction[input][0]] = (position[direction[input][0]] + direction[input][1]) % world_length planner.updatePlanQueue(move_tmr(position)) elif input: leia(input, lexicon, planner) else: planner.updatePlanQueue(None)
import sys sys.path.insert(0, './plan_selection') import planManager from semantics.semantics import * import leia if __name__ == "__main__": pm = planManager.planManager() while (1): sentence = raw_input("Enter a sentence\n") try: if int(sentence) == 0: tmr = 0 except: tmr = leia.leia(sentence)[0] pm.updatePlanQueue(tmr) print "I have {} plan(s) in my queue".format(len(pm.plans))
read_list = [sys.stdin] timeout = 0.3 if __name__ == "__main__": #Primary listening loop lexicon = Lexicon() load() pm = planManager() global read_list dead = False while(not dead): while read_list: ready = select.select(read_list, [], [], timeout)[0] if not ready: pm.updatePlanQueue(0) else: for file in ready: line = file.readline() if not line: read_list.remove(file) elif line.rstrip(): if str(line.lower().strip("\n")) == "die agent die!": print "Goodbye cruel world!" dead = True sys.exit(0) else: print "The input was", line leia(line, lexicon, pm)