#NEWLINE# def cache_majorities( self , attribute ) : #NEWLINE# #INDENT# self . _majority [ attribute ] = defaultdict ( Counter ) #NEWLINE# all_questions = self . _qdb . questions_with_pages ( ) #NEWLINE# for page in all_questions : #NEWLINE# #INDENT# for qq in all_questions [ page ] : #NEWLINE# #INDENT# if ( qq . fold == 'train' ) : #NEWLINE# #INDENT# self . _majority [ attribute ] [ qq . page ] [ getattr ( qq , attribute , '' ) . split ( ':' ) [ 0 ] . lower ( ) ] += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for page in self . _majority [ page ] : #NEWLINE# #INDENT# self . _majority [ attribute ] [ page ] = self . _majority [ attribute ] [ page ] . most_common ( 1 ) [ 0 ] [ 0 ]