EvaluationMetric.set_numSentences(1);
EvaluationMetric.set_refsPerSen(1);
EvaluationMetric.set_refSentences(refSentences);
BLEU bleu = new BLEU();
// testSentences[i] stores the candidate translation for the i'th sentence
String[] testSentences = new String[1];
testSentences[0] = test;
try {
// Check BLEU score matches
double actualScore = bleu.score(testSentences);
double expectedScore = 0.2513;
double acceptableScoreDelta = 0.00001f;
Assert.assertEquals(actualScore, expectedScore, acceptableScoreDelta);
// Check sufficient statistics match
int[] actualSS = bleu.suffStats(testSentences);
int[] expectedSS = {14,27,8,26,5,25,3,24,27,23};
Assert.assertEquals(actualSS[0], expectedSS[0], 0); // 1-gram matches
Assert.assertEquals(actualSS[1], expectedSS[1], 0); // 1-gram total
Assert.assertEquals(actualSS[2], expectedSS[2], 0); // 2-gram matches