def main(): parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('-c', dest='config') parser.add_argument('-f', dest='test_file') parser.add_argument('-e', dest='epoch', type=int) args = parser.parse_args() config.parse(args.config) config.cuda = False vocab = load_vocabulary() model = build_model(len(vocab.word2index), load_ckpt=True, ckpt_epoch=args.epoch) config.use_cuda = False model.cpu() bot = BotAgent(model, vocab) if args.test_file is not None: with open(args.test_file) as file: question_list = [] for line in file: question_list.append(line[:-1]) for question in question_list: print('> %s' % question) print('bot: %s' % bot.response(question)) else: while True: user_input = input('me: ') if user_input.strip() == '': continue print('%s: %s' % ('bot', bot.response(user_input)))
def main(): vocab = load_vocabulary() model = build_model(len(vocab.word2index), load_ckpt=True, ckpt_epoch=ckpt_epoch) bot = BotAgent(model, vocab) while True: user_input = raw_input('me: ') if user_input.strip() == '': continue print('%s: %s' % (BOT_NAME, bot.response(user_input)))
def select_proper_checkpoint(): for epoch in arange(MIN_EPOCH, MAX_EPOCH + STEP_SIZE, STEP_SIZE): vocab = load_vocabulary() model = build_model(len(vocab.word2index), load_checkpoint=True, checkpoint_epoch=epoch, print_module=False) data_set = build_data_loader(batch_size=BATCH_SIZE) test_loss = model_evaluate(model, data_set) print('EPOCH %d Test PPL: %.4f' % (epoch, math.exp(test_loss)))
def main(): vocab = load_vocabulary() model = build_model(len(vocab.word2index), load_ckpt=True, ckpt_epoch=ckpt_epoch) bot = BotAgent(model, vocab) # IRIS.initialise() while True: user_input = raw_input('me: ') if user_input.strip() == '': continue Iris_resp = IRIS.main(user_input, 2) if Iris_resp != '---$---' and len(Iris_resp.split()) <= 10 : print('%s: %s' % ("Iris", Iris_resp)) else: print('%s: %s' % ("Seq", bot.response(user_input)))
def main(): vocab = load_vocabulary() model = build_model(len(vocab.word2index), load_ckpt=True, ckpt_epoch=ckpt_epoch) bot = BotAgent(model, vocab) while True: user_input = raw_input('me: ') if user_input.strip() == '': continue response = bot.response(user_input) print('%s: %s' % (BOT_NAME, response)) curr_sys = platform.system() if curr_sys == 'Linux': os.system('echo %s | festival --tts' % response) elif curr_sys == 'Darwin': os.system('say &s' % response)