def extract_test_sentences(string, comment_chars='#%;', encoding=None):
 if (encoding is not None):
  string = string.decode(encoding)
 sentences = []
 for sentence in string.split('\n'):
  if ((sentence == '') or (sentence[0] in comment_chars)):
   continue
  split_info = sentence.split(':', 1)
  result = None
  if (len(split_info) == 2):
   if (split_info[0] in ['True', 'true', 'False', 'false']):
    result = (split_info[0] in ['True', 'true'])
    sentence = split_info[1]
   else:
    result = int(split_info[0])
    sentence = split_info[1]
  tokens = sentence.split()
  if (tokens == []):
   continue
  sentences += [(tokens, result)]
 return sentences

def extract_test_sentences ( string , comment_chars = '#%;' , encoding = None ) : if ( encoding is not None ) : string = string . decode ( encoding ) sentences = [ ] for sentence in string . split ( '\n' ) : if ( ( sentence == '' ) or ( sentence [ 0 ] in comment_chars ) ) : continue split_info = sentence . split ( ':' , 1 ) result = None if ( len ( split_info ) == 2 ) : if ( split_info [ 0 ] in [ 'True' , 'true' , 'False' , 'false' ] ) : result = ( split_info [ 0 ] in [ 'True' , 'true' ] ) sentence = split_info [ 1 ] else : result = int ( split_info [ 0 ] ) sentence = split_info [ 1 ] tokens = sentence . split ( ) if ( tokens == [ ] ) : continue sentences += [ ( tokens , result ) ] return sentences
parses a string with one test sentence per line .