fix BLEU for empty output
This commit is contained in:
parent
f289cafc03
commit
c10f3579c6
@ -226,6 +226,7 @@ gevalCore' BLEU _ = gevalCoreWithoutInput (Prelude.map Prelude.words . DLS.split
|
||||
bleuFuse (a1, a2, a3, a4, a5, a6, a7, a8, a9) (b1, b2, b3, b4, b5, b6, b7, b8, b9) = (a1+b1, a2+b2, a3+b3, a4+b4, a5+b5, a6+b6, a7+b7, a8+b8, a9+b9)
|
||||
brevityPenalty c r
|
||||
| c >= r = 1.0
|
||||
| c == 0 && r > 0 = 0.0
|
||||
| otherwise = exp (1.0 - (r /. c))
|
||||
|
||||
gevalCore' Accuracy _ = gevalCoreWithoutInput strip strip hitOrMiss averageC id
|
||||
|
@ -48,6 +48,8 @@ main = hspec $ do
|
||||
runGEvalTest "bleu-complex" `shouldReturnAlmost` 0.6211
|
||||
it "perfect translation" $
|
||||
runGEvalTest "bleu-perfect" `shouldReturnAlmost` 1.0000
|
||||
it "empty translation" $
|
||||
runGEvalTest "bleu-empty" `shouldReturnAlmost` 0.0000
|
||||
describe "Accuracy" $ do
|
||||
it "simple example" $
|
||||
runGEvalTest "accuracy-simple" `shouldReturnAlmost` 0.6
|
||||
|
4
test/bleu-empty/bleu-empty-solution/test-A/out.tsv
Normal file
4
test/bleu-empty/bleu-empty-solution/test-A/out.tsv
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
|
||||
|
|
1
test/bleu-empty/bleu-empty/config.txt
Normal file
1
test/bleu-empty/bleu-empty/config.txt
Normal file
@ -0,0 +1 @@
|
||||
--metric BLEU
|
4
test/bleu-empty/bleu-empty/test-A/expected.tsv
Normal file
4
test/bleu-empty/bleu-empty/test-A/expected.tsv
Normal file
@ -0,0 +1,4 @@
|
||||
Litwo, Ojczyzno moja! ty jesteś jak zdrowie;
|
||||
Ile cię trzeba cenić, ten tylko się dowie,
|
||||
Kto cię stracił. Dziś piękność twą w całej ozdobie
|
||||
Widzę i opisuję, bo tęsknię po tobie.
|
|
Loading…
Reference in New Issue
Block a user