def test_score(): cand = "中华人民共和国" ref = "中华人民共和国公民" bleu = Bleu(N_SIZE) bleu.add_inst(cand, ref) s = bleu.get_score() print('score: {}'.format(s))
def test_score(): # init all argument data = read_json() rouge_eval = RougeL() bleu_eval = Bleu() for idx, (ref_key, cand_key) in enumerate(data): ref_sent = data[idx][ref_key] cand_sent = data[idx][cand_key] rouge_eval.add_inst(cand_sent, ref_sent) bleu_eval.add_inst(cand_sent, ref_sent) bleu_score = bleu_eval.get_score() rouge_score = rouge_eval.get_score() print('bleu score: {}, rouge score: {}'.format(bleu_score, rouge_score))