#NEWLINE# def get_example( ) : #NEWLINE# #INDENT# 'Make an example for training and testing.  Outputs a tuple\n    (label, features) where label is +1 if capital letters are the majority,\n    and -1 otherwise; and features is a list of letters.\n    ' #NEWLINE# features = random . sample ( string . ascii_letters , NUM_SAMPLES ) #NEWLINE# num_capitalized = len ( [ letter for letter in features if ( letter in string . ascii_uppercase ) ] ) #NEWLINE# num_lowercase = len ( [ letter for letter in features if ( letter in string . ascii_lowercase ) ] ) #NEWLINE# if ( num_capitalized > num_lowercase ) : #NEWLINE# #INDENT# label = 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# label = ( - 1 ) #NEWLINE# #UNINDENT# return ( label , features )