Difficulty: Easy Tags: NLP
Snap's caption-moderation pipeline needs a first-pass tokenizer before any heavier model runs.
Every unrecognized word must fall back to a single <unk> token, never crash the pipeline.
Given a fixed vocabulary mapping word to id (id 0 reserved for <pad>, id 1 reserved for
<unk>), split the input text on whitespace and map each word to its id, using <unk>'s id for any
out-of-vocabulary word.
V
word_1 id_1
...
word_V id_V
caption text on one line
Space-separated token ids, one line.
1 <= V <= 10^4, caption up to 500 charactersInput
3
the 2
cat 3
sat 4
the cat sat on mat
Output
2 3 4 1 1
No results yet
Run your code to check it against the examples, or submit to run every test.