Map tokens to integer ids with a vocabulary dict, using unk_id for every token that is not in the vocabulary.
Implement solve(tokens, vocab, unk_id).
Returns. Return a list of ids with the same length as tokens.
Example 1
Input:
solve(['the', 'cat', 'zzz'], {'the': 1, 'cat': 2}, 0)
Output:
[1, 2, 0]
Example 2
Input:
solve([], {'a': 1}, 0)
Output:
[]
No results yet
Run your code to check it against the examples, or submit to run every test.