C2_W3 assignment UNQ_C8 count_n_grams

Why does this exercise prepend the start token n times, not (n-1) times? Based on lecture, for trigram, the start token should be pretended only twice, not three times. So, wouldn’t it make more sense to revise the exercise to prepend the start token only (n-1) times?

Hi @younglee

That is a good question and the explanation for that is provided below the cell:

Take a look to the ('<s>', '<s>') element in the bi-gram dictionary. Although for a bi-gram you will only require one starting mark, as in the element ('<s>', 'i'), this ('<s>', '<s>') element will be helpful when computing the probabilities using tri-grams (the corresponding count will be used as denominator).


Thank you for the clarificaiton!