All problems
Slot BIO Decode
Problem
Decode slot tags into a dictionary mapping each slot label to the list of extracted entity strings.
B- starts a new value, I- continues the current slot when the label matches, an I- with a different label starts a new value of that label, and O closes the current slot. Multi-token values are joined with spaces.
Hint
Flush the current value whenever the label changes or an O appears.
Test cases
case 1
in: [["fly","to","paris"],["O","O","B-city"]]
expected: {"city":["paris"]}
case 2
in: [["new","york","to","boston"],["B-city","I-city","O","B-city"]]
expected: {"city":["new york","boston"]}
case 3
in: [["i","am","here"],["O","B-state","O"]]
expected: {"state":["am"]}
case 4
in: [[],[]]
expected: {}
case 5
in: [["a","b"],["B-x","I-y"]]
expected: {"x":["a"],"y":["b"]}
Starter codePython
def slot_bio_decode(tokens, tags):
# Your code here
pass5 test cases · run your code against them in the editor