Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-399

Abbreviation Detection Heuristic

Problem

A token looks like an abbreviation when it is all uppercase with at least two letters, or a dotted uppercase pattern such as "U.S.".

Given the token list, return the tokens matching this heuristic in order.

Hint

Strip trailing periods before checking case and content.

Test cases

case 1
in: [["NASA","and","U.S."]]
expected: ["NASA","U.S."]
case 2
in: [["hello","A"]]
expected: []
case 3
in: [["AI","ML"]]
expected: ["AI","ML"]
Starter codePython
def abbreviation_detection_heuristic(tokens):
    # Your code here
    pass

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