コード例 #1
0
ファイル: evaluate.py プロジェクト: lagka/sockeye
def raw_corpus_bleu(hypotheses: Iterable[str], references: Iterable[str], offset: Optional[float] = 0.01) -> float:
    """
    Simple wrapper around sacreBLEU's BLEU without tokenization and smoothing.

    :param hypotheses: Hypotheses stream.
    :param references: Reference stream.
    :param offset: Smoothing constant.
    :return: BLEU score as float between 0 and 1.
    """
    return sacrebleu.raw_corpus_bleu(hypotheses, [references], smooth_floor=offset).score / 100.0
コード例 #2
0
ファイル: evaluate.py プロジェクト: talkhouli/sockeye
def raw_corpus_bleu(hypotheses: Iterable[str],
                    references: Iterable[str],
                    offset: Optional[float] = 0.01) -> float:
    """
    Simple wrapper around sacreBLEU's BLEU without tokenization and smoothing.

    :param hypotheses: Hypotheses stream.
    :param references: Reference stream.
    :param offset: Smoothing constant.
    :return: BLEU score as float between 0 and 1.
    """
    return sacrebleu.raw_corpus_bleu(hypotheses, [references],
                                     smooth_floor=offset).score / 100
コード例 #3
0
def test_statistics(hypothesis, reference, expected_stat):
    result = sacrebleu.raw_corpus_bleu(hypothesis, reference, .01)
    stat = Statistics(result.counts, result.totals)
    assert stat == expected_stat
コード例 #4
0
def test_effective_order(hypotheses, references, expected_bleu):
    bleu = sacrebleu.raw_corpus_bleu(hypotheses, [references], .01).score / 100
    assert abs(bleu - expected_bleu) < EPSILON
コード例 #5
0
def test_degenerate_uneven(hypotheses, references):
    with pytest.raises(EOFError, match=r'.*stream.*'):
        sacrebleu.raw_corpus_bleu(hypotheses, references)
コード例 #6
0
ファイル: test_bleu.py プロジェクト: Vita112/my-notebook
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
コード例 #7
0
ファイル: test_bleu.py プロジェクト: lagka/sockeye
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
コード例 #8
0
ファイル: test_bleu.py プロジェクト: lagka/sockeye
def test_statistics(hypothesis, reference, expected_stat):
    result = sacrebleu.raw_corpus_bleu(hypothesis, reference, .01)
    stat = Statistics(result.counts, result.totals)
    assert stat == expected_stat
コード例 #9
0
ファイル: test_bleu.py プロジェクト: lagka/sockeye
def test_effective_order(hypotheses, references, expected_bleu):
    bleu = sacrebleu.raw_corpus_bleu(hypotheses, [references], .01).score / 100
    assert abs(bleu - expected_bleu) < EPSILON
コード例 #10
0
ファイル: test_bleu.py プロジェクト: lagka/sockeye
def test_degenerate_uneven(hypotheses, references):
    with pytest.raises(EOFError, match=r'.*stream.*'):
        sacrebleu.raw_corpus_bleu(hypotheses, references)