def word_count(documents):
 collector = defaultdict(list)
 for document in documents:
  for (word, count) in wc_mapper(document):
   collector[word].append(count)
 return [output for (word, counts) in collector.items() for output in wc_reducer(word, counts)]

def word_count ( documents ) : collector = defaultdict ( list ) for document in documents : for ( word , count ) in wc_mapper ( document ) : collector [ word ] . append ( count ) return [ output for ( word , counts ) in collector . items ( ) for output in wc_reducer ( word , counts ) ]
count the words in the input documents using mapreduce .