#NEWLINE# def review_split_mapper( self , categories , review ) : #NEWLINE# #INDENT# 'Split a review into pairs of words and yield out \n        (start word, category), (follow word, count), combining\n        repeated pairs into a single emission.\n        ' #NEWLINE# pair_counts = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for pair in word_pairs ( review ) : #NEWLINE# #INDENT# pair_counts [ pair ] = ( pair_counts . get ( pair , 0 ) + 1 ) #NEWLINE# #UNINDENT# for ( ( start , follow ) , count ) in pair_counts . iteritems ( ) : #NEWLINE# #INDENT# for category in categories : #NEWLINE# #INDENT# ( yield ( ( start , category ) , ( follow , count ) ) )