#NEWLINE# def positivity_reducer( self , category_word , biz_positivities ) : #NEWLINE# #INDENT# "Read (category, word), (biz_id, positivity), and compute\n        the average positivity for the category-word pair. Skip words\n        that don't occur frequently enough or for not enough unique\n        businesses.\n\n        Emits rating, (category, # reviews with word, word).\n        " #NEWLINE# ( category , word ) = category_word #NEWLINE# businesses = set ( ) #NEWLINE# positivities = [ ] #NEWLINE# for ( biz_id , positivity ) in biz_positivities : #NEWLINE# #INDENT# businesses . add ( biz_id ) #NEWLINE# positivities . append ( positivity ) #NEWLINE# #UNINDENT# if ( len ( biz_id ) < MINIMUM_BUSINESSES ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# ( avg , total ) = avg_and_total ( positivities ) #NEWLINE# if ( total < MINIMUM_OCCURENCES ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# ( yield ( int ( ( avg * 100 ) ) , ( category , total , word ) ) )