Screen Link: Learn data science with Python and R projects
Word_counts_per_sms = {unique_word: [0] * len(training_set['SMS']) for unique_word in vocabulary}
for index, sms in enumerate(training_set['SMS']):
for word in sms:
word_counts_per_sms[word][index] += 1
Hello! I’m having a hard time to understand the following part of the code above:
Word_counts_per_sms = {unique_word: [0] * len(training_set['SMS']) for unique_word in vocabulary}
I do understand how’s the indexing is working, but the [0] * len(training_set[‘SMS’]) is a bit confusing for me. Does it mean that it generates a list of zeroes that is equal to the amount of each unique_word(key) in vocabulary so that I have a corresponding value ([0]) for all of those indexes?
Thank you!