Your question is Count Word Occurrences in Text. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Niantic telemetry and content pipelines may deliver text in chunks rather than as one complete string. Given an iterable stream of text chunks and a list of requested words, count how many times each requested word appears.
Matching is case-insensitive. A word is a contiguous sequence of ASCII letters, and any non-letter character separates words. A requested word is guaranteed to contain only ASCII letters. Do not concatenate the entire stream before processing it, and correctly handle a word split across two chunks.
Implement count_stream_words(chunks, words), where chunks is an iterable of strings and words is a list of requested words. Return a dictionary mapping each requested word, normalized to lowercase, to its occurrence count. Include every requested word in the result, even when its count is zero. If the input list contains the same word more than once, return one key for that word.
def count_stream_words(chunks, words):