def processSingle(path):
    if config.GPU == True:
        ptrNet = PointerNetwork(config.HIDDEN_SIZE).cuda()
    else:
        ptrNet = PointerNetwork(config.HIDDEN_SIZE)

    ptrNet.load_state_dict(torch.load(path))

    nlp = spacy.load("en_core_web_sm")
    sentences = [
        "this is definitely a difficult sentence", "your plan seems excellent",
        "it is really working", "let me start with a poem",
        "he is sure to pass the exam", "we meet every wednesday",
        "do plan to we it tomorrow", "i like working on brain",
        "development good is a this", "i am going to canada",
        "The script that I am describing here mainly for training and validation "
    ]

    if True:
        for origLine in sentences:
            print("")
            inputLine, outputLine = processSentence(nlp, ptrNet, origLine)
            print("Input Sentence: ", inputLine)
            print("Outpt Sentence: ", outputLine)
            print("Orig  Sentence: ", origLine)

    else:
        lines = open("../data/englishSentences_test.dat").read().splitlines()
        for i in range(7):
            print("\n")
            origLine = random.choice(lines)
            inputLine, outputLine = processSentence(nlp, ptrNet, origLine)
            print("Input Sentence: ", inputLine)
            print("Outpt Sentence: ", outputLine)
            print("Orig  Sentence: ", origLine)
Beispiel #2
0
def modelEvaluate(path):
    if config.GPU == True:
        ptrNet = PointerNetwork(config.HIDDEN_SIZE).cuda()
    else:
        ptrNet = PointerNetwork(config.HIDDEN_SIZE)

    ptrNet.load_state_dict(torch.load(path))
    evaluateWordSort(ptrNet, 1)
Beispiel #3
0
def modelEvaluate(accuracyStats, path):
    if config.GPU == True:
        ptrNet = PointerNetwork(config.HIDDEN_SIZE).cuda()
    else:
        ptrNet = PointerNetwork(config.HIDDEN_SIZE)

    ptrNet.load_state_dict(torch.load(path))
    for epoch in range(EPOCHS):
        evaluateWordSort(accuracyStats, ptrNet, 1)
    printAccStats(accuracyStats)
Beispiel #4
0
def modelEvaluate(accuracyStats, path):
    if config.GPU == True:
        ptrNet = PointerNetwork(config.HIDDEN_SIZE).cuda()
    else:
        ptrNet = PointerNetwork(config.HIDDEN_SIZE)

    ptrNet.load_state_dict(torch.load(path))
    for sentenceLength in range(4, 11):
        print(sentenceLength)
        evaluateWordSort(accuracyStats, ptrNet, sentenceLength)
    printAccStats(accuracyStats)