<s> from mrjob . job import MRJob <EOL> import re <EOL> WORD_RE = re . compile ( r"<STR_LIT>" ) <EOL> class MRMostUsedWord ( MRJob ) : <EOL> def mapper_get_words ( self , _ , line ) : <EOL> for word in WORD_RE . findall ( line ) : <EOL> yield ( word . lower ( ) , <NUM_LIT:1> ) <EOL> def combiner_count_words ( self , word , counts ) : <EOL> yield ( word , sum ( counts ) ) <EOL> def reducer_count_words ( self , word , counts ) : <EOL> yield None , ( sum ( counts ) , word ) <EOL> def reducer_find_max_word ( self , _ , word_count_pairs ) : <EOL> yield max ( word_count_pairs ) <EOL> def steps ( self ) : <EOL> return [ <EOL> self . mr ( mapper = self . mapper_get_words , <EOL> combiner = self . combiner_count_words , <EOL> reducer = self . reducer_count_words ) , <EOL> self . mr ( reducer = self . reducer_find_max_word ) <EOL> ] <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> MRMostUsedWord . run ( ) </s>
