Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_offset(hypothesis, reference, expected_with_offset, expected_without_offset):
score_without_offset = sacrebleu.raw_corpus_bleu(hypothesis, reference, 0.0).score / 100
assert abs(expected_without_offset - score_without_offset) < EPSILON
score_with_offset = sacrebleu.raw_corpus_bleu(hypothesis, reference, 0.1).score / 100
assert abs(expected_with_offset - score_with_offset) < EPSILON
def test_offset(hypothesis, reference, expected_with_offset, expected_without_offset):
score_without_offset = sacrebleu.raw_corpus_bleu(hypothesis, reference, 0.0).score / 100
assert abs(expected_without_offset - score_without_offset) < EPSILON
score_with_offset = sacrebleu.raw_corpus_bleu(hypothesis, reference, 0.1).score / 100
assert abs(expected_with_offset - score_with_offset) < EPSILON
def test_bleu(hypotheses, references, expected_bleu):
bleu = sacrebleu.raw_corpus_bleu(hypotheses, [references], .01).score / 100
assert abs(bleu - expected_bleu) < EPSILON
def test_degenerate_uneven(hypotheses, references):
with pytest.raises(EOFError, match=r'.*stream.*'):
sacrebleu.raw_corpus_bleu(hypotheses, references)
def test_offset(hypothesis, reference, expected_with_offset, expected_without_offset):
score_without_offset = sacrebleu.raw_corpus_bleu(hypothesis, reference, 0.0).score / 100
assert abs(expected_without_offset - score_without_offset) < EPSILON
score_with_offset = sacrebleu.raw_corpus_bleu(hypothesis, reference, 0.1).score / 100
assert abs(expected_with_offset - score_with_offset) < EPSILON
def test_offset(hypothesis, reference, expected_with_offset, expected_without_offset):
score_without_offset = sacrebleu.raw_corpus_bleu(hypothesis, reference, 0.0).score / 100
assert abs(expected_without_offset - score_without_offset) < EPSILON
score_with_offset = sacrebleu.raw_corpus_bleu(hypothesis, reference, 0.1).score / 100
assert abs(expected_with_offset - score_with_offset) < EPSILON
def test_bleu(hypotheses, references, expected_bleu):
bleu = sacrebleu.raw_corpus_bleu(hypotheses, [references], .01).score / 100
assert abs(bleu - expected_bleu) < EPSILON
def test_degenerate_statistics(statistics, offset, expected_score):
score = sacrebleu.compute_bleu(statistics[0].common, statistics[0].total, statistics[1], statistics[2], smooth_method='floor', smooth_value=offset).score / 100
assert score == expected_score
def test_scoring(statistics, expected_score):
score = sacrebleu.compute_bleu(statistics[0].common, statistics[0].total, statistics[1], statistics[2]).score / 100
assert abs(score - expected_score) < EPSILON
def test_chrf(hypotheses, references, expected_score):
score = sacrebleu.corpus_chrf(hypotheses, references, 6, 3)
assert abs(score - expected_score) < EPSILON