Esempio n. 1
0
def test():
    with open('dataset_new.json', 'r') as f:
        dataset = json.load(f)
    form = InputForm()
    if form.validate_on_submit():

        intent = action_predict(str(form.input_data.data))
        log(intent)
        if intent != "none":
            k = dsl(intent)
            reply = k.generate()
            log(reply)
            input_text = form.input_data.data
            #print(input_text)
            dat = {"question": input_text, "answer": reply}
            form.input_data.data = ""
            return render_template('index.html',
                                   reply=reply["text"],
                                   form=form,
                                   input_text=input_text)
        else:
            reply = reply_predict(str(form.input_data.data))
            input_text = form.input_data.data
            dat = {"question": input_text, "answer": reply}
            dataset.append(dat)
            with open("dataset_new.json", "w") as w:
                json.dump(dataset, w)
            form.input_data.data = ""
            return render_template('index.html',
                                   reply=reply,
                                   form=form,
                                   input_text=input_text)
    return render_template('index.html', form=form)
Esempio n. 2
0
def test():
    form = InputForm()
    if form.validate_on_submit():

        intent = action_predict(str(form.input_data.data))
        log(intent)
        if intent != "none":
            k = dsl(intent)
            reply = k.generate()
            log(reply)
            input_text = form.input_data.data
            #print(input_text)
            form.input_data.data = ""
            return render_template('index.html',
                                   reply=reply["text"],
                                   form=form,
                                   input_text=input_text)
        else:
            reply = reply_predict(str(form.input_data.data))
            input_text = form.input_data.data

            form.input_data.data = ""
            return render_template('index.html',
                                   reply=reply,
                                   form=form,
                                   input_text=input_text)
    return render_template('index.html', form=form)
Esempio n. 3
0
def process_msg(message_text):
    intent = action_predict(str(message_text))  #predicting action
    if intent != "none":  #if the message is a command
        k = dsl(intent)
        reply = k.generate()
        return reply
    else:  #if the message is just chitchat
        reply = reply_predict(message_text)
        return reply
Esempio n. 4
0
from torch.autograd import Variable
import torch

training_data = []

with open('action_dataset.json') as data_file:
    data = json.load(data_file)

for line in data:
    #fetching training data
    training_data.append(line)

action_train(20000, training_data)  #training the model
#testing with a new input
#print("say wahts tinkerhub")
print("intent:" + action_predict("how is it"))
"""
accuracy= 0 % input= tell me more about RIT actual= website guess= website
accuracy= 0 % input= give me more information actual= website guess= website
accuracy= 1 % input= who is the principal  actual= website guess= website
accuracy= 0 % input= give me the phone number actual= contact guess= contact
accuracy= 31 % input= open college website actual= website guess= website
accuracy= 43 % input= open college website actual= website guess= website
accuracy= 0 % input= navigate me to RIT actual= location guess= location
accuracy= 30 % input= give me more information actual= website guess= website
accuracy= 28 % input= good bye actual= goodbye guess= goodbye
accuracy= 69 % input= have a nice day actual= goodbye guess= goodbye
accuracy= 0 % input= navigate me to RIT actual= location guess= location
accuracy= 76 % input= open college website actual= website guess= website
accuracy= 67 % input= i have to go actual= goodbye guess= goodbye
accuracy= 80 % input= open college website actual= website guess= website
Esempio n. 5
0
from torch.autograd import Variable
import torch

training_data = []

with open('app/datasets/action_dataset.json') as data_file:
    data = json.load(data_file)

for line in data:
    #fetching training data
    training_data.append(line)

action_train(20000, training_data)  #training the model
#testing with a new input
#print("say wahts tinkerhub")
print("intent:" + action_predict("hello"))
"""
accuracy= 0 % input= tell me more about RIT actual= website guess= website
accuracy= 0 % input= give me more information actual= website guess= website
accuracy= 1 % input= who is the principal  actual= website guess= website
accuracy= 0 % input= give me the phone number actual= contact guess= contact
accuracy= 31 % input= open college website actual= website guess= website
accuracy= 43 % input= open college website actual= website guess= website
accuracy= 0 % input= navigate me to RIT actual= location guess= location
accuracy= 30 % input= give me more information actual= website guess= website
accuracy= 28 % input= good bye actual= goodbye guess= goodbye
accuracy= 69 % input= have a nice day actual= goodbye guess= goodbye
accuracy= 0 % input= navigate me to RIT actual= location guess= location
accuracy= 76 % input= open college website actual= website guess= website
accuracy= 67 % input= i have to go actual= goodbye guess= goodbye
accuracy= 80 % input= open college website actual= website guess= website
Esempio n. 6
0
from torch.autograd import Variable
import torch

training_data = []

with open('action_dataset.json') as data_file:
    data = json.load(data_file)

for line in data:
    #fetching training data
    training_data.append(line)

action_train(10000, training_data)  #training the model
#testing with a new input
print("how can i reach RIT")
print("intent:" + action_predict("how can i reach RIT"))
"""
accuracy= 0 % input= tell me more about RIT actual= website guess= website
accuracy= 0 % input= give me more information actual= website guess= website
accuracy= 1 % input= who is the principal  actual= website guess= website
accuracy= 0 % input= give me the phone number actual= contact guess= contact
accuracy= 31 % input= open college website actual= website guess= website
accuracy= 43 % input= open college website actual= website guess= website
accuracy= 0 % input= navigate me to RIT actual= location guess= location
accuracy= 30 % input= give me more information actual= website guess= website
accuracy= 28 % input= good bye actual= goodbye guess= goodbye
accuracy= 69 % input= have a nice day actual= goodbye guess= goodbye
accuracy= 0 % input= navigate me to RIT actual= location guess= location
accuracy= 76 % input= open college website actual= website guess= website
accuracy= 67 % input= i have to go actual= goodbye guess= goodbye
accuracy= 80 % input= open college website actual= website guess= website