Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-285

POS Tagging Accuracy with Ignore Set

Problem

Compute POS tagging accuracy while ignoring selected gold tags. gold_tags and pred_tags are parallel label lists, and ignore is the set of gold tags to skip.

The lists are zipped to the shorter length. Return correct non-ignored predictions divided by the number of non-ignored positions, or 0.0 when none are counted.

Hint

Skip positions whose gold tag is in the ignore set before counting.

Test cases

case 1
in: [["N","V","P"],["N","N","P"],[]]
expected: 0.6666666666666666
case 2
in: [["N","V","P"],["N","N","P"],["P"]]
expected: 0.5
case 3
in: [["N"],[],[]]
expected: 0
case 4
in: [[],[],[]]
expected: 0
case 5
in: [["P","P"],["N","N"],["P"]]
expected: 0
Starter codePython
def pos_tagging_accuracy(gold_tags, pred_tags, ignore):
    # Your code here
    pass

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