W3 ex8 Count_n_grams

Hi, I got “4 Tests passed, 2 Tests failed” in the test cases, but I can’t even spot the mistake, not to speak of how to ammend this. Your help will be highly appreciated!


Expected: {(‘’, ‘’): 2, (‘’, ‘i’): 1, (‘i’, ‘like’): 1, (‘like’, ‘a’): 2, (‘a’, ‘cat’): 2, (‘cat’, ‘’): 2, (‘’, ‘this’): 1, (‘this’, ‘dog’): 1, (‘dog’, ‘is’): 1, (‘is’, ‘like’): 1}
Got: {(‘’, ‘’): 2, (‘’, ‘i’): 1, (‘i’, ‘like’): 1, (‘like’, ‘a’): 2, (‘a’, ‘cat’): 2, (‘cat’, ‘’): 2, (‘’,): 2, (‘’, ‘this’): 1, (‘this’, ‘dog’): 1, (‘dog’, ‘is’): 1, (‘is’, ‘like’): 1}.
Wrong output dictionary.
Expected: {(‘-1’, ‘-1’, ‘-1’): 4, (‘-1’, ‘-1’, ‘in’): 1, (‘-1’, ‘in’, ‘sunset’): 1, (‘in’, ‘sunset’, ‘sky’): 1, (‘sunset’, ‘sky’, ‘is’): 1, (‘sky’, ‘is’, ‘red’): 1, (‘is’, ‘red’, ‘-2’): 1, (‘-1’, ‘-1’, ‘i’): 1, (‘-1’, ‘i’, ‘like’): 1, (‘i’, ‘like’, ‘a’): 1, (‘like’, ‘a’, ‘cat’): 2, (‘a’, ‘cat’, ‘-2’): 2, (‘-1’, ‘-1’, ‘this’): 1, (‘-1’, ‘this’, ‘dog’): 1, (‘this’, ‘dog’, ‘is’): 1, (‘dog’, ‘is’, ‘like’): 1, (‘is’, ‘like’, ‘a’): 1, (‘-1’, ‘-1’, ‘really’): 1, (‘-1’, ‘really’, ‘really’): 1, (‘really’, ‘really’, ‘long’): 1, (‘really’, ‘long’, ‘sentence’): 1, (‘long’, ‘sentence’, ‘.’): 1, (‘sentence’, ‘.’, ‘it’): 1, (‘.’, ‘it’, ‘is’): 1, (‘it’, ‘is’, ‘very’): 1, (‘is’, ‘very’, ‘long’): 1, (‘very’, ‘long’, ‘indeed’): 1, (‘long’, ‘indeed’, ‘;’): 1, (‘indeed’, ‘;’, ‘so’): 1, (‘;’, ‘so’, ‘long’): 1, (‘so’, ‘long’, ‘…’): 1, (‘long’, ‘…’, ‘-2’): 1}
Got: {(‘-1’, ‘-1’, ‘-1’): 4, (‘-1’, ‘-1’, ‘in’): 1, (‘-1’, ‘in’, ‘sunset’): 1, (‘in’, ‘sunset’, ‘sky’): 1, (‘sunset’, ‘sky’, ‘is’): 1, (‘sky’, ‘is’, ‘red’): 1, (‘is’, ‘red’, ‘-2’): 1, (‘red’, ‘-2’): 1, (‘-2’,): 4, (‘-1’, ‘-1’, ‘i’): 1, (‘-1’, ‘i’, ‘like’): 1, (‘i’, ‘like’, ‘a’): 1, (‘like’, ‘a’, ‘cat’): 2, (‘a’, ‘cat’, ‘-2’): 2, (‘cat’, ‘-2’): 2, (‘-1’, ‘-1’, ‘this’): 1, (‘-1’, ‘this’, ‘dog’): 1, (‘this’, ‘dog’, ‘is’): 1, (‘dog’, ‘is’, ‘like’): 1, (‘is’, ‘like’, ‘a’): 1, (‘-1’, ‘-1’, ‘really’): 1, (‘-1’, ‘really’, ‘really’): 1, (‘really’, ‘really’, ‘long’): 1, (‘really’, ‘long’, ‘sentence’): 1, (‘long’, ‘sentence’, ‘.’): 1, (‘sentence’, ‘.’, ‘it’): 1, (‘.’, ‘it’, ‘is’): 1, (‘it’, ‘is’, ‘very’): 1, (‘is’, ‘very’, ‘long’): 1, (‘very’, ‘long’, ‘indeed’): 1, (‘long’, ‘indeed’, ‘;’): 1, (‘indeed’, ‘;’, ‘so’): 1, (‘;’, ‘so’, ‘long’): 1, (‘so’, ‘long’, ‘…’): 1, (‘long’, ‘…’, ‘-2’): 1, (‘…’, ‘-2’): 1}.

In the first instance you show, you can see that you have one extra value included in your output:

('<e>',): 2

So you need to figure out what bug would cause that.

1 Like