Exemplo n.º 1
0
def main(opt):
    translator = build_translator(opt)
    out_file = codecs.open(opt.output, 'w+', 'utf-8')

    src_iter = make_text_iterator_from_file(opt.src)
    if opt.tgt is not None:
        tgt_iter = make_text_iterator_from_file(opt.tgt)
    else:
        tgt_iter = None
    translator.translate(src_data_iter=src_iter,
                         tgt_data_iter=tgt_iter,
                         batch_size=opt.batch_size,
                         out_file=out_file)
    out_file.close()
Exemplo n.º 2
0
def main(opt):

    translator = build_translator(opt)
    out_file = codecs.open(opt.output, 'w+', 'utf-8')

    src_iter = make_text_iterator_from_file(opt.src)

    if opt.tgt is not None:
        tgt_iter = make_text_iterator_from_file(opt.tgt)
    else:
        tgt_iter = None

    if opt.structure1 is not None:
        structure_iter1 = make_text_iterator_from_file(opt.structure1)
    else:
        structure_iter1 = None

    if opt.structure2 is not None:
        structure_iter2 = make_text_iterator_from_file(opt.structure2)
    else:
        structure_iter2 = None

    if opt.structure3 is not None:
        structure_iter3 = make_text_iterator_from_file(opt.structure3)
    else:
        structure_iter3 = None

    if opt.structure4 is not None:
        structure_iter4 = make_text_iterator_from_file(opt.structure4)
    else:
        structure_iter4 = None

    if opt.structure5 is not None:
        structure_iter5 = make_text_iterator_from_file(opt.structure5)
    else:
        structure_iter5 = None

    translator.translate(src_data_iter=src_iter,
                         tgt_data_iter=tgt_iter,
                         structure_iter1=structure_iter1,
                         structure_iter2=structure_iter2,
                         structure_iter3=structure_iter3,
                         structure_iter4=structure_iter4,
                         structure_iter5=structure_iter5,
                         batch_size=opt.batch_size,
                         out_file=out_file)
    out_file.close()
Exemplo n.º 3
0
def main(opt, model_path):

    translator = build_translator(opt, model_path)
    out_file = codecs.open(opt.output, 'w+', 'utf-8')
    # X_train, X_valid, X_test, y_train, y_valid, y_test = data_loader.test_mosei_emotion_data()
    X_train, X_valid, X_test, y_train, y_valid, y_test = data_loader.read_cmumosei_emotion_pkl(
    )
    src_path = X_test
    src_iter = make_text_iterator_from_file(src_path)  #(opt.src)
    tgt_path = y_test
    tgt_iter = make_text_iterator_from_file(tgt_path)
    # if opt.tgt is not None:
    #   tgt_iter = make_text_iterator_from_file(opt.tgt)
    # else:
    #   tgt_iter = None
    translator.translate(src_data_iter=src_iter,
                         tgt_data_iter=tgt_iter,
                         batch_size=opt.batch_size,
                         out_file=out_file)
    out_file.close()