Compute a word frequency dictionary from a list of tokenized sentences. Input is a list of sentences, where each sentence is itself a list of tokens.
Input: [["i", "love", "ml"], ["i", "love", "coding"]]
Output: {"i": 2, "love": 2, "ml": 1, "coding": 1}
Input: [["hello", "hello"], ["world"]]
Output: {"hello": 2, "world": 1}
Input: []
Output: {}
Initialize an empty dictionary, then iterate through all sentences and words to build counts.
Sign in to take notes on this problem
Accepts: array
Compute a word frequency dictionary from a list of tokenized sentences. Input is a list of sentences, where each sentence is itself a list of tokens.
Input: [["i", "love", "ml"], ["i", "love", "coding"]]
Output: {"i": 2, "love": 2, "ml": 1, "coding": 1}
Input: [["hello", "hello"], ["world"]]
Output: {"hello": 2, "world": 1}
Input: []
Output: {}
Initialize an empty dictionary, then iterate through all sentences and words to build counts.
Sign in to take notes on this problem
Accepts: array