Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-319

QA Answer Normalization String

Problem

Normalize an answer string for exact-match evaluation. Lowercase the text, replace every non-alphanumeric character with a space, drop the English articles a, an, and the, and join the remaining tokens with single spaces.

Return the normalized string, which is empty when nothing remains.

Hint

Apply the same canonicalization to both prediction and gold before comparing for exact match.

Test cases

case 1
in: ["The Cat!"]
expected: "cat"
case 2
in: ["a dog"]
expected: "dog"
case 3
in: ["An APPLE, a pear"]
expected: "apple pear"
case 4
in: [" "]
expected: ""
case 5
in: ["What's this?"]
expected: "what s this"
Starter codePython
def qa_answer_normalization(text):
    # Your code here
    pass

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