예제 #1
0
def init():
    try:
        test = QueryDB.connection("bolt://localhost:7687", "neo4j", "test")
    except:
        print("Cannot connect to server")
        sys.exit()

    page = Tk()

    cypher = StringVar()
    output = StringVar()

    page.title("NLP Input")
    page.geometry("700x350")

    app = Frame(page)
    app.grid()

    btn1 = Button(app,
                  text="Submit",
                  command=lambda: setOutput(e1.get(), cypher, output, test))

    lbl1 = Label(app, text="Enter your search: ")
    lbl2 = Label(app, text="Query in Cypher: ")
    lbl3 = Label(app, textvariable=cypher)
    lbl4 = Label(app, text="Query result: ")
    lbl5 = Label(app, textvariable=output)

    e1 = Entry(app)

    lbl1.grid(row=0)
    lbl2.grid(row=2)

    e1.grid(row=0, column=1)
    lbl3.grid(row=2, column=1)

    btn1.grid(row=0, column=2, padx=10, pady=10)

    lbl4.grid(row=3, column=0)
    lbl5.grid(row=3, column=1)

    page.mainloop()
예제 #2
0
import parse
import QueryDB

myConnection = QueryDB.connection("bolt://localhost:7687", "neo4j", "test")

infile = open("testQueries.txt", "r")
translations = []
results = []
for line in infile:
    translations.append(parse.init(line.strip()))
for line in translations:
    results.append(myConnection.run_Return_Query(line).strip())
infile.close

infile = open("testResults.txt", "r")
answers = []
for line in infile:
    answers.append(line.strip())
for i in range(0, len(answers)):
    if (answers[i] == results[i]):
        print("Querie ", i, " successful")
    else:
        print("Querie ", i, " failed!")
        print("\tExpected:\t", answers[i])
        print("\tActual:\t", results[i])
infile.close