def test(encdec): # Loads vocab. src_vocab = make_vocab(SRC_TRAIN_FILE, SRC_VOCAB_SIZE) trg_vocab = make_vocab(TRG_TRAIN_FILE, TRG_VOCAB_SIZE) inv_trg_vocab = make_inv_vocab(trg_vocab) for line in sys.stdin: trg_ids = test_batch(encdec, src_vocab, trg_vocab, [line_to_sent(line.strip(), src_vocab)])[0] # Prints the result. print(" ".join(inv_trg_vocab[wid] for wid in trg_ids))
def test(encdec, args): # Loads vocab. src_vocab = make_vocab(SRC_TRAIN_FILE, args.src_vocab) trg_vocab = make_vocab(TRG_TRAIN_FILE, args.trg_vocab) inv_trg_vocab = make_inv_vocab(trg_vocab) for line in sys.stdin: sent = [line_to_sent(line.strip(), src_vocab)] trg_ids = test_batch(encdec, src_vocab, trg_vocab, sent, args.generation_limit)[0] # Prints the result. print(" ".join(inv_trg_vocab[wid] for wid in trg_ids))