def compute_nmt_en2zh()

in utils/compute_score.py [0:0]


def compute_nmt_en2zh(file_path, model_path):
    references = []
    candidates = []
    comet_data = []

    # model_path = download_model("Unbabel/XCOMET-XL")
    model = load_from_checkpoint(model_path)  # XCOMET-XL/checkpoints/model.ckpt
    print("金融英中翻译")
    with open(file_path, 'r') as input_file:
        print("Reading\t" + file_path)
        sample_list = json.load(input_file)

        for line in sample_list:
            if line['sub_task'] == '金融英中翻译':
                references.append(" ".join(jieba.lcut(line['output'])))
                candidates.append(" ".join(jieba.lcut(line['predict'])))
                src = line['instruction'].replace(
                    "你是一个金融行业专家,请将下面金融领域的英文内容翻译成准确、专业的中文。\n英文:", "").replace("中文:", "").strip()
                comet_data.append({
                    "src": src,
                    "mt": line['predict'],
                    "ref": line['output']
                })
        _, bleu4 = bleu_score(references, candidates)
        model_output = model.predict(comet_data, batch_size=32, gpus=1)
        print(model_output.system_score)  # system-level score
        print('\n')
    return bleu4, model_output.system_score