本文提到的翻译准确率测试指标是BLEU,以及使用Python库-fuzzywuzzy来计算相似度
一、基于BLEU值评估
1.只评估一段话,代码如下
from nltk.translate.bleu_score import sentence_bleu, SmoothingFunction
# 机器翻译结果
machine_translation = "How are you"
# 参考翻译列表
human_translations = ["How have you been lately?"]
# 使用SmoothingFunction.method1
chencherry = SmoothingFunction()
# 计算BLEU分数
bleu_score = sentence_bleu(human_translations, machine_translation, smoothing_function=chencherry.method1)
print(f"BLEU score: {
bleu_score:.4f}")
评估结果如下,BLEU分数为0.17,换算为百分比后为17%

2.需要评估多段内容,将待评估的文字统一放入excel,代码如下
import pandas as pd
from nltk.translate.bleu_score import sentence_bleu

最低0.47元/天 解锁文章
374

被折叠的 条评论
为什么被折叠?



