Skip to content
DeepForgeby svx
All problems
MediumNLPnlp-328

Contraction Expansion Count

Problem

Contraction expansion turns forms like "don't" into tokens ["do", "not"] using a fixed table for "don't", "can't", "won't", "i'm", and "it's".

Given a whitespace-tokenized sentence, return the expanded token list lowercased.

Hint

Map known contractions and pass everything else through lowercased.

Test cases

case 1
in: [["I'm","sure"]]
expected: ["i","am","sure"]
case 2
in: [["don't","won't"]]
expected: ["do","not","will","not"]
case 3
in: [["can't","stop"]]
expected: ["can","not","stop"]
Starter codePython
def contraction_expansion_count(tokens):
    # Your code here
    pass

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