Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
order: int = CHRF_ORDER,
beta: float = CHRF_BETA,
remove_whitespace: bool = True) -> CHRF:
"""
Computes Chrf on a corpus.
:param hypotheses: Stream of hypotheses.
:param references: Stream of references
:param order: Maximum n-gram order.
:param remove_whitespace: Whether to delete all whitespace from hypothesis and reference strings.
:param beta: Defines importance of recall w.r.t precision. If beta=1, same importance.
:return: Chrf score.
"""
corpus_statistics = get_corpus_statistics(hypotheses, references, order=order, remove_whitespace=remove_whitespace)
avg_precision, avg_recall = _avg_precision_and_recall(corpus_statistics, order)
return CHRF(_chrf(avg_precision, avg_recall, beta=beta))
order: int = CHRF_ORDER,
beta: float = CHRF_BETA,
remove_whitespace: bool = True) -> CHRF:
"""
Computes ChrF on a single sentence pair.
:param hypothesis: Hypothesis string.
:param reference: Reference string.
:param order: Maximum n-gram order.
:param remove_whitespace: Whether to delete whitespaces from hypothesis and reference strings.
:param beta: Defines importance of recall w.r.t precision. If beta=1, same importance.
:return: Chrf score.
"""
statistics = get_sentence_statistics(hypothesis, reference, order=order, remove_whitespace=remove_whitespace)
avg_precision, avg_recall = _avg_precision_and_recall(statistics, order)
return CHRF(_chrf(avg_precision, avg_recall, beta=beta))