All problems
Entity Type Count
Problem
Count how many entities of each type appear in a BIO tag sequence.
Every B- tag starts one entity and contributes to its label count. Return a dictionary mapping each label to its entity count.
Hint
Only B- tags open entities, so ignore I- tags entirely.
Test cases
case 1
in: [["B-PER","I-PER","O","B-LOC","B-PER"]]
expected: {"PER":2,"LOC":1}
case 2
in: [["O"]]
expected: {}
case 3
in: [[]]
expected: {}
case 4
in: [["B-MISC","I-MISC","B-MISC"]]
expected: {"MISC":2}
Starter codePython
def entity_type_count(tags):
# Your code here
pass4 test cases · run your code against them in the editor