def most_popular_word_reducer(user, words_and_counts):
 word_counts = Counter()
 for (word, count) in words_and_counts:
  word_counts[word] += count
 (word, count) = word_counts.most_common(1)[0]
 (yield (user, (word, count)))

def most_popular_word_reducer ( user , words_and_counts ) : word_counts = Counter ( ) for ( word , count ) in words_and_counts : word_counts [ word ] += count ( word , count ) = word_counts . most_common ( 1 ) [ 0 ] ( yield ( user , ( word , count ) ) )
given a sequence of pairs .