Code QuizIntermediate Handling Out-of-Vocabulary Tokens
Find why this encoder crashes on unknown words.
Codepython
vocab = {"<UNK>": 0, "hello": 1, "world": 2}
def encode(token, vocab):
return vocab[token]
print(encode("hello", vocab))
print(encode("foobar", vocab))What is the bug when encoding an out-of-vocabulary token?