C2_W3 assignment: problem with preprocess_data function


I got the following error message the test_preprocess_data(preprocess_data), even though I have the expected outcomes as obtained outcomes.
Wrong number of unknown tokens in the test_data_replaced list. Check the unknown token value and how you are using it.


Dear @Ala_Jabari1,
Welcome to the community.
Can you please share the screenshot of errors.

1 Like

Hi @Ala_Jabari1

This error is probably because you are using global scope variable for unknown token value.

Please make sure you use unknown_token variable in your implementations and not ā€œ<unk>ā€.

You can learn more about this (variable scope, function parameters in Python) by searching on the internet and finding many explanations like:

This is the knowledge every Python user should know not only for this course.



Thanks for your help ā€¦ the problem is solved after replacing ā€œā€ with unknown_token


im also getting a similar error can someone please tell me where Iā€™m going wrong

Hi, I have the same problem. Did you work it out? Thanks!

I also had the same problem. Resolved it by passing the unknown_token parameter to the replace_oov_words_by_unk instead of assuming that it will take it from the default value in the parameter.