How to use the sacrebleu.corpus_chrf function in sacrebleu

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_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
github awslabs / sockeye / test / unit / test_chrf.py View on Github external
def test_chrf_keep_whitespace(hypotheses, references, expected_score):
    score = sacrebleu.corpus_chrf(hypotheses, references, 6, 3, remove_whitespace=False)
    assert abs(score - expected_score) < EPSILON
github awslabs / sockeye / test / unit / 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
github facebookresearch / vizseq / vizseq / scorers / chrf.py View on Github external
def score_corpus_multiprocess(
            self, hypothesis: List[str], references: List[List[str]]
    ) -> float:
        if self.n_workers == 1:
            corpus_score = sb.corpus_chrf(hypothesis, references[0]).score
        else:
            batches = list(
                self._batch(hypothesis, references, n_batches=self.n_workers)
            )
            corpus_statistics = [0 for _ in range(sb.CHRF_ORDER * 3)]
            with ProcessPoolExecutor(max_workers=self.n_workers) as executor:
                futures = [
                    executor.submit(
                        sb.get_corpus_statistics, b[0], b[1][0]
                    )
                    for b in batches
                ]
                progress = as_completed(futures)
                if self.verbose:
                    progress = tqdm(progress)
                for future in progress:
github joeynmt / joeynmt / joeynmt / metrics.py View on Github external
def chrf(hypotheses, references):
    """
    Character F-score from sacrebleu

    :param hypotheses: list of hypotheses (strings)
    :param references: list of references (strings)
    :return:
    """
    return sacrebleu.corpus_chrf(hypotheses=hypotheses, references=references)