Exercise 7 of Assignment


I have problem with exercise 7, I checked the previous replies about this problem and I added the unknown_token to replace_oov_words_by_unk, but when running the test case, I get the error : “name ‘unknown_token’ is not defined”, can anyone help me?

Thank you.

Is unknown_token defined as a parameter in your function?

Yes, It is a parameter of function: replace_oov_words_by_unk

Hi @Zoha_Azimi,

You have changed your function parameters for Exercise 7. This is from your notebook:

def preprocess_data(train_data, test_data, count_threshold):

And this is the original and how it should be:

def preprocess_data(train_data, test_data, count_threshold, unknown_token=“”, get_words_with_nplus_frequency=get_words_with_nplus_frequency, replace_oov_words_by_unk=replace_oov_words_by_unk):

Never ever should you change your function parameters to make your code work. You will run into all sorts of problems, both within the assignment and with the autograder.

In Ex 7, fix this and use unknown_token in place of "<unk>" and your code will run.

Also, if there are other places where you have changed function parameters, kindly change them back to the original state.


Thank you so much @Mubsi , yeah, that was a mistake I didn’t notice.
I am not planning to do it again, but if this happens by mistake, how can I reach to the original code after that?

Hi @Zoha_Azimi,

By following these instructions: Coursera | Online Courses & Credentials From Top Educators. Join for Free | Coursera