Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-159

Exact Match Normalization

Problem

Return True when prediction and gold are equal after QA normalization: lowercase, replace non-alphanumeric characters with spaces, drop the articles a, an, and the, and join the remaining tokens with single spaces.

Two inputs that both normalize to the empty string count as a match.

Hint

Apply the same canonicalization to both strings, then compare equality.

Test cases

case 1
in: ["The Cat!","cat"]
expected: true
case 2
in: ["a dog","The dog."]
expected: true
case 3
in: ["cat","cats"]
expected: false
case 4
in: ["",""]
expected: true
Starter codePython
import re
def exact_match_normalization(prediction, gold):
    # Your code here
    pass

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