Skip to content
DeepForgeby svx
All problems
HardNLPnlp-305

chrF3 Character N-gram F-score

Problem

Compute a chrF3 score using character n-grams of order 1, 2, and 3. For each order, compute the clipped character n-gram F-score between candidate and reference, then return the arithmetic mean over orders.

An order where exactly one side lacks n-grams scores 0.0, an order where both sides lack n-grams is skipped, and 0.0 is returned when no order is scored. Return 0.0 when there are no matches at any scored order.

Hint

Average the per-order clipped F-scores, skipping only orders where both strings are too short.

Test cases

case 1
in: ["abc","abc"]
expected: 1
case 2
in: ["abc","abd"]
expected: 0.38888888888888884
case 3
in: ["ab","a"]
expected: 0.3333333333333333
case 4
in: ["",""]
expected: 0
case 5
in: ["a","b"]
expected: 0
Starter codePython
def chrf3(candidate, reference):
    # Your code here
    pass

5 test cases · run your code against them in the editor