How to use sacrebleu - 10 common examples

To help you get started, we’ve selected a few sacrebleu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mjpost / sacreBLEU / test / test_bleu.py View on Github external
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
github mjpost / sacreBLEU / test / test_bleu.py View on Github external
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
github awslabs / sockeye / test / unit / test_bleu.py View on Github external
def test_bleu(hypotheses, references, expected_bleu):
    bleu = sacrebleu.raw_corpus_bleu(hypotheses, [references], .01).score / 100
    assert abs(bleu - expected_bleu) < EPSILON
github awslabs / sockeye / test / unit / test_bleu.py View on Github external
def test_degenerate_uneven(hypotheses, references):
    with pytest.raises(EOFError, match=r'.*stream.*'):
        sacrebleu.raw_corpus_bleu(hypotheses, references)
github awslabs / sockeye / test / unit / test_bleu.py View on Github external
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
github awslabs / sockeye / test / unit / test_bleu.py View on Github external
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
github mjpost / sacreBLEU / test / test_bleu.py View on Github external
def test_bleu(hypotheses, references, expected_bleu):
    bleu = sacrebleu.raw_corpus_bleu(hypotheses, [references], .01).score / 100
    assert abs(bleu - expected_bleu) < EPSILON
github mjpost / sacreBLEU / test / test_bleu.py View on Github external
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
github awslabs / sockeye / test / unit / test_bleu.py View on Github external
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
github mjpost / sacreBLEU / test / test_chrf.py View on Github external
def test_chrf(hypotheses, references, expected_score):
    score = sacrebleu.corpus_chrf(hypotheses, references, 6, 3)
    assert abs(score - expected_score) < EPSILON