Week 3 - C2_W3_Assignment - replace_oov_words_by_unk

Hello,

Week 3 - C2_W3_Assignment

Someone could help me with this issue please?

I am creting the function: “replace_oov_words_by_unk” and getting this error in the unit test:

Wrong number of unknown tokens in the corpus. Check the unknown token value and how you are using it.
Expected: 5
Got: 0.
Wrong output values.
Expected: [[‘sky’, ‘is’, ‘blue’, ‘.’], [‘-1’, ‘are’, ‘-1’, ‘.’], [‘space’, ‘is’, ‘infinite’, ‘-1’], [‘-1’, ‘-1’, ‘sky’, ‘is’, ‘red’]]
Got: [[‘sky’, ‘is’, ‘blue’, ‘.’], [“'replacement_token” ‘are’, ‘replacement_token’, ‘.’], [‘space’, ‘is’, ‘infinite’, ‘replacement_token’], ['replacement_token, ‘replacement_token’, ‘sky’, ‘is’, ‘red’]].
4 Tests passed
2 Tests failed

I am using: “<”+“unk”+“>” as my replacement token.

1 Like

What they show as “Got:” is what your code produced. My interpretation of the output it shows is that you are using replacement_token as your replacement token. :nerd_face:

Looking at the “Expected” value they show, it looks like they are expecting you to use ‘-1’ as the replacement token, not <unk>.

It might be worth reading through the instructions again and comparing that to what your code is actually doing.

2 Likes

Hi! You’re absolutely right — my mistake was that I didn’t use the parameter of the function.
It’s working now. Thanks!

2 Likes