Ejemplo n.º 1
0
def sentence_caller(arg):
	try:
		g = parse_sentence(sentence.get().lower().replace(".", ""))
	except WordNotFound as w:
		tkMessageBox.showerror("Word Not Found", "I do not know the word \"%s\"" % str(w.args[0]))
	else:
		g.mutate(dictionary)
		database.add_info(g)
		buffer = withoutdictionary()
		print(buffer.edges)
		buffer = buffer.as_pydot_graph().create_png()
		buffer = StringIO(buffer)
		image1 = ImageTk.PhotoImage(Image.open(buffer))		 
		# get the image size
		w = image1.width()
		h = image1.height()
		sentence['width'] = w
		root.geometry("%dx%d" % (w, h+50))
		panel1['image'] = image1
		panel1.image = image1
		sentence.delete(0, tk.END)
Ejemplo n.º 2
0
        while True:
            line = raw_input("? ")
            if line == "":
                break
            else:
                query.add(*line.split(" "))
        print database.query(query)
    elif command.endswith(".png"):
        withoutdictionary().as_pydot_graph().write_png(command)
    elif "pp" == command:
        print prettify(withoutdictionary())
    elif "exit" == command:
        break
    elif ">" == command:
        while True:
            line = raw_input("> ")
            if line == "":
                break
            words = line.split(" ")
            if last_query is not None:
                words = tuple(last_query[word] if word in last_query else word for word in words)
            database.add(*words)
    else:
        try:
            g = parse_sentence(command.replace(".", ""))
        except WordNotFound as w:
            print 'I do not know the word "%s"' % w
        else:
            g.mutate(dictionary)
            database.add_info(g)