当前位置:   article > 正文

BLEU指标的计算示例_blue指标计算代码

blue指标计算代码

题目如下:

根据下图例子,计算下面机器翻译译文的BLEU-4值 (列出1-4元文法的统计数)
在这里插入图片描述
在这里插入图片描述

解:由题意得

1 − 4 元的统计数如下表所示: 1-4 元的统计数如下表所示: 14元的统计数如下表所示:
1-gram count ref count-clip it 1 0 0 is 1 1 1 a 1 1 1 nice 1 1 1 day 1 1 1 today 1 1 1

1-gramcountrefcount-clipit100is111a111nice111day111today111
1-gramitisanicedaytodaycount111111ref011111count-clip011111

2-gram count ref count-clip it is 1 0 0 is a 1 1 1 a nice 1 1 1 nice day 1 1 1 day today 1 0 0

2-gramcountrefcount-clipit is100is a111a nice111nice day111day today100
2-gramit isis aa nicenice dayday todaycount11111ref01110count-clip01110

3-gram count ref count-clip it is a 1 0 0 is a nice 1 1 1 a nice day 1 1 1 nice day today 1 0 0

3-gramcountrefcount-clipit is a100is a nice111a nice day111nice day today100
3-gramit is ais a nicea nice daynice day todaycount1111ref0110count-clip0110

4-gram count ref count-clip it is a nice 1 0 0 is a nice day 1 1 1 a nice day today 1 0 0

4-gramcountrefcount-clipit is a nice100is a nice day111a nice day today100
4-gramit is a niceis a nice daya nice day todaycount111ref010count-clip010

由表可得
p 1 = 5 6 , p 2 = 3 5 , p 3 = 2 4 , p 4 = 1 3 p_1 = \frac56 , p_2 = \frac35 , p_3 = \frac24 , p_4 = \frac13 p1=65p2=53p3=42p4=31
易知
c = 6 , r = 5 c = 6,r = 5 c=6,r=5

c > r c > r c>r

B P = 1 BP = 1 BP=1
画表如下:
Translation p 1 p 2 p 3 p 4 BP 人工译文: Today is a nice day 机器译文: It is a nice day today 5 6 3 5 2 4 1 3 1 ‾ \overline{

Translationp1p2p3p4BP人工译文:Today is a nice day机器译文:It is a nice day today563524131
} 人工译文:机器译文:TranslationToday is a nice dayIt is a nice day todayp165p253p342p431BP1
因为 N = 4 N = 4 N=4 ,故 w n = 1 4 w_n = \frac14 wn=41

所以
BLEU-4 = B P ∗ exp ⁡ ( ∑ n = 1 N w n l o g P n ) = 1 × exp ⁡ ( 1 4 × ( log ⁡ ( p 1 ) + log ⁡ ( p 2 ) + log ⁡ ( p 3 ) + l o g ( p 4 ) ) ) = exp ⁡ ( 1 4 × log ⁡ ( p 1 p 2 p 3 p 4 ) ) = exp ⁡ ( 1 4 × l o g ( 5 6 × 3 5 × 2 4 × 1 3 ) ) = exp ⁡ ( 1 4 × l o g ( 1 12 ) ) ≈ 0.537

BLEU-4=BPexp(n=1NwnlogPn)=1×exp(14×(log(p1)+log(p2)+log(p3)+log(p4)))=exp(14×log(p1p2p3p4))=exp(14×log(56×35×24×13))=exp(14×log(112))0.537
BLEU-4=BPexp(n=1NwnlogPn)=1×exp(41×(log(p1)+log(p2)+log(p3)+log(p4)))=exp(41×log(p1p2p3p4))=exp(41×log(65×53×42×31))=exp(41×log(121))0.537

倘若大佬发现什么错误,敬请斧正,感谢感谢!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/369308
推荐阅读
  

闽ICP备14008679号