Distributed Word Count
Start Timer
0:00:00
Given a list of pages where each page is a string of text, write a function word_count that returns a dictionary mapping each word to its total frequency across all pages. The input could hold thousands of pages, so aim for an approach that processes pages independently and merges the results.
Note: Words are the whitespace-separated tokens of a page converted to lowercase (punctuation is kept as part of the token).
Example:
Input:
pages = [
"The quick brown fox",
"The fox jumps over the lazy dog",
]
Output:
word_count(pages) -> {'the': 3, 'quick': 1, 'brown': 1, 'fox': 2, 'jumps': 1, 'over': 1, 'lazy': 1, 'dog': 1}
.
.
.
.
.
.
.
.
.
Comments